|
-
Jan 31st, 2008, 04:40 AM
#1
Thread Starter
Junior Member
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
-
Jan 31st, 2008, 05:30 AM
#2
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
-
Jan 31st, 2008, 09:10 AM
#3
Addicted Member
Re: vb6 AND adodb.connection
Close the recordset and Connection object at the end of the routine
vb Code:
rs.Close
Conn.Close
set rs=nothing
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|