Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54

    Unanswered: hOW CAN I CHECK TO SEE IF A CONNECTION TO THE DATABSE IS ALREADY OPEN

    Is it possible if the connection to a database is already open so i can close it in a if statement.

    I am using this but doesnt seem to work all the time..

    If ActiveConnection = True Then
    rs.Close
    Set rs = Nothing
    Else
    rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    End If

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Re: hOW CAN I CHECK TO SEE IF A CONNECTION TO THE DATABSE IS ALREADY OPEN

    If ActiveConnection = nothing Then
    rs.Open sql, CurrentProject.Connection, adOpenKeyset,adLockOptimistic

    Else
    rs.Close
    Set rs = Nothing
    End If

  3. #3
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54
    i have used this and i get the following error

    compile error : invalid use of object

  4. #4
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Angry

    OK Ok OK

    if the connection is known tru-out the application use this

    where cnn is your ADODB.Connection

    CNN.STATE


    if it returns -------0 or adStateClosed ---- it is closed
    if it returns -------1 or adStateOpen ---- it is open
    if it returns -------2 or adStateConnecting---- it is Connecting
    if it returns -------3 or adStateExecuting ---- executing a command
    if it returns -------4 or adStateFetching ---- rows of the Recordset object are being fetched

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •