Message 1 of 12
ADO problem with a query

Not applicable
03-04-2008
10:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been using DAO succesfully for a while now, but I wanted to check if ADO will be a bit quicker at this new project I'm workign on, so I gave it a shot. It works fine if I want to get the whole table, but as soon as I plug into it SQL Query it returns nothing 😞 This is the same query I use in DAO and it works fine, but no working in ADO, can someone clue me in?
Sub testADO()
Dim objCnn As New ADODB.Connection
Dim objRs As New ADODB.Recordset
Dim objCmd As New ADODB.Command
Dim qry As String
Dim category As String
category = "CONDUIT"
objCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\Shared Data\AutoCad Support\BOM DATABASE\Stock Items.mdb;Persist Security Info=False"
qry = "SELECT [Old Ref Numbers].[Ref Number], [Stock Items Combined].Description, [Stock Items Combined].[Material Number], [Stock Items Combined].Type FROM [Old Ref Numbers] RIGHT JOIN [Stock Items Combined] ON [Old Ref Numbers].[Material Number] = [Stock Items Combined].[Material Number]WHERE ((([Stock Items Combined].Description) Like ""*" & itemType & "*"" And ([Stock Items Combined].Description) Like """ & listFilter & """) AND (([Stock Items Combined].Type)=""" & category & """))ORDER BY [Stock Items Combined].Description;"
objRs.Open qry, objCnn, adOpenForwardOnly, adLockReadOnly, adCmdText
With objRs
Do Until .EOF
MsgBox .Fields(0)
.MoveNext
Loop
End With
End Sub
Thanks.
Sub testADO()
Dim objCnn As New ADODB.Connection
Dim objRs As New ADODB.Recordset
Dim objCmd As New ADODB.Command
Dim qry As String
Dim category As String
category = "CONDUIT"
objCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\Shared Data\AutoCad Support\BOM DATABASE\Stock Items.mdb;Persist Security Info=False"
qry = "SELECT [Old Ref Numbers].[Ref Number], [Stock Items Combined].Description, [Stock Items Combined].[Material Number], [Stock Items Combined].Type FROM [Old Ref Numbers] RIGHT JOIN [Stock Items Combined] ON [Old Ref Numbers].[Material Number] = [Stock Items Combined].[Material Number]WHERE ((([Stock Items Combined].Description) Like ""*" & itemType & "*"" And ([Stock Items Combined].Description) Like """ & listFilter & """) AND (([Stock Items Combined].Type)=""" & category & """))ORDER BY [Stock Items Combined].Description;"
objRs.Open qry, objCnn, adOpenForwardOnly, adLockReadOnly, adCmdText
With objRs
Do Until .EOF
MsgBox .Fields(0)
.MoveNext
Loop
End With
End Sub
Thanks.