Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Sql query - no records 1

Status
Not open for further replies.

mbowles

Programmer
Aug 27, 2001
41
US
I have the following code:
Code:
    Dim result As String
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Dim var As String
        
    cn.Open "Provider=sqloledb;" & _
           "Data Source=server;" & _
           "Initial Catalog=TR2Master;" & _
           "User Id=id;" & _
           "Password=pass"
 
    rs.Open "select Long_Description from table where code= '" & strText & "'", cn ', adOpenDynamic, adLockOptimistic
    'rs.MoveFirst
    
    WriteToLog ("opened recordset: " & rs.EOF & " " & rs.BOF)
    result = "No Description!"
    Do Until rs.EOF = True
        result = rs.Fields("Long_Description")
        WriteToLog ("found record")
    Loop
    
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing
    
    getDescription = result
Query analyzer shows 1 record, but thru VB6, I get true for both BOF and EOF and thus no result. Anyone see what I may have goofed?
 
Code:
"'", cn ', adOpenDynamic
What's that apostrophe doing after cn?

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top