Results 1 to 7 of 7

Thread: help... About Connection and Recordset

  1. #1

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    Dear All...

    I need some help...

    How should I do if I want to check whether a connection or recordset is open or closed ?

    Thx a lot...

    BRgds,
    Wille
    Junior VB Programmer

  2. #2
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    which database object u r using???
    if its ADO u can use state property of ADO connection object and recordset object
    Thanx Manish

  3. #3

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    Dear Manish,

    I used ADO Connection...

    I mean everytime I want to use :

    Myconn.close

    or

    MyRecord.close

    I want to check it first whether it is open or closed...

    And everytime I want to open a connection or recordset, I also want to check it first...

    Thx a lot...
    Help me plz...

    Wille
    Junior VB Programmer

  4. #4
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    U can use the state property of the recordset and connection object

    if dbConnection.state=adstateopen then
    ' place here the code to use existing connection
    else
    ' place here the codes for opening a connection
    endif

    there are the possible values for State property

    adStateOpen
    adStateClose
    adStateConnecting
    adStateExecuting
    adStateFetching

    Brgds Manish

  5. #5

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    Dear Manish...

    You said that the statement would be like below :

    if dbConnection.state=adstateopen then
    ' place here the code to use existing connection
    else
    ' place here the codes for opening a connection
    endif

    then... I'm still confuse about the code to use existing connection....
    Could u explain more... how to use existing connection ???

    Thx again.....

    Wille
    Junior VB Programmer

  6. #6
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    HI
    it is like this
    let say u hv previously created a connection object and opened it for operations and now again u want to use that connection and u want to check if the connection is still open or not. Let say u want to open a recordset
    now before setting the currentconnection property of then recordset place this code
    if dbconnection.state=adStateClose then
    ' this part will be executed only when the the connection is close before setting the active conection property of the recordset object connection must be open...
    so her place the code to open the connection then.
    end if

    now set the activeconnection property of the recordset.
    and now open the recordset
    Thanx Manish


  7. #7

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    Dear Manish...

    Thx for your help...
    it helps me a lot...

    Wille
    Junior VB Programmer

Posting Permissions

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



Click Here to Expand Forum to Full Width