Results 1 to 3 of 3

Thread: vb6 AND adodb.connection

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    31

    vb6 AND adodb.connection

    hai
    i am using VB6 .. i am using one function named ListCardSLNO().. the code is as below

    Private Sub ListCardSLNO()
    Dim Conn As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim sql, csnval As String
    csnval = Trim(txtCSN.Text) & "%"

    If Conn.State = 0 Then
    Conn.Open "KeyGen"
    End If

    sql = "select * from esc where status = 'N' and slno like '" & csnval & "' ORDER BY slno"
    Rs.Open sql, Conn, adOpenStatic, adLockOptimistic
    Set DCCsn.RowSource = Rs
    DCCsn.ListField = "slno" 'Bind the DataCombo to the ADO Recordset

    DCCsn.MatchEntry = dblBasicMatching 'ExtendedMatching
    End Sub

    DCCsn is the name of Data Combo ... in this function i am trying to populate combo with the slno retreived from a table named esc ... the problem is that first time the values are loading to the combo .. theres no error for the first time .. but second time its showing that object already opened ... whats the mistake i ve done .. how i can correct it ...

    plz any body help
    Any Help appreciated

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: vb6 AND adodb.connection

    I don't see where your closing Rs (Rs.Close).

    I always close the RS and set it to nothing when I'm done with it.

    Rs.Close
    Set Rs = nothing

  3. #3
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: vb6 AND adodb.connection

    Close the recordset and Connection object at the end of the routine

    vb Code:
    1. rs.Close
    2. Conn.Close
    3.  
    4. set rs=nothing
    5. set conn=nothing
    Regards
    Srinivasan Baskaran
    India

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