ADO recordset different than query (1 Viewer)

casey

Registered User.
Local time
Today, 13:18
Joined
Dec 5, 2000
Messages
448
Hello,

I have an Access query that returns one record. However, using ADO I open the same query as a recordset and it gives no results(rs.EOF = true and rs.RecordCount =0??? Any ideas?

Hoping that someone has had this happen and can explain without posting all the code.

Code:
Dim cn As New ADODB.Connection, i As Integer
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
             "Data Source=C:\Documents and Settings\MyDatabase.mdb"
cn.Open strConn

strSQL = "SELECT Act.lngRecordId FROM tblAction AS Act where strPrototype Like 'S*' And Act.lngRecordId = 1378"

Set Rs = New ADODB.Recordset
With Rs
    Set .ActiveConnection = cn
    .LockType = adLockOptimistic
    .CursorType = adOpenDynamic
    .Open strSQL
End With
    
'my test to see how many results--shows .EOF = true 
'while my Access query has 1 results???  
Do While Rs.EOF = False
  'my code but no results to process???
Loop
  
  Rs.Close
  Set Rs = Nothing
  Set Db = Nothing
 

casey

Registered User.
Local time
Today, 13:18
Joined
Dec 5, 2000
Messages
448
I'm being told that this may be due to a wildcard of "*" in the SQL that needs to be "%" for ADO to recognize???
 

tehNellie

Registered User.
Local time
Today, 13:18
Joined
Apr 3, 2007
Messages
751
Yes, if you change the * for a % the query works.
 

casey

Registered User.
Local time
Today, 13:18
Joined
Dec 5, 2000
Messages
448
Yes, that's it. It's been so long since I've used vb it's like re-learning this stuff.

Thanks.
 

Users who are viewing this thread

Top Bottom