I have tried every combintion I can think of to get a VB5 recordset
SQL query using the LIKE keyword to work recognizing the '*' wildcard
character, but with no success. Why doesn't the LIKE keyword work with
VB5 using ADO or DAO?
Dim T$
T$ = App.Path & "\MyAccess2000D B.mdb"
T$ = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & T$
ConnectStr = T$
With myConnect
On Error Resume Next
.ConnectionStri ng = ConnectStr
.ConnectionTime out = 10
.Open
On Error GoTo 0
End With
Set CorpRS = New ADODB.Recordset
CorpRS.ActiveCo nnection = myConnect
CorpRS.CursorTy pe = adOpenDynamic
CorpRS.LockType = adLockOptimisti c
field$ = "Symbol"
term$ = "IBM"
'this works but I can't get wildcards to work
sql$ = "Select * from Corporations WHERE " & field$ & " Like '" &
term$ & "'"
CorpRS.Open sql$
I cannot equate term$ to anything and get the query to recognize
wildcards.
For example, if term$ = "*M*", I want the query to return MSFT, MMM,
MCD, etc.
Any ideas?
Thank you.
---
Allen
SQL query using the LIKE keyword to work recognizing the '*' wildcard
character, but with no success. Why doesn't the LIKE keyword work with
VB5 using ADO or DAO?
Dim T$
T$ = App.Path & "\MyAccess2000D B.mdb"
T$ = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & T$
ConnectStr = T$
With myConnect
On Error Resume Next
.ConnectionStri ng = ConnectStr
.ConnectionTime out = 10
.Open
On Error GoTo 0
End With
Set CorpRS = New ADODB.Recordset
CorpRS.ActiveCo nnection = myConnect
CorpRS.CursorTy pe = adOpenDynamic
CorpRS.LockType = adLockOptimisti c
field$ = "Symbol"
term$ = "IBM"
'this works but I can't get wildcards to work
sql$ = "Select * from Corporations WHERE " & field$ & " Like '" &
term$ & "'"
CorpRS.Open sql$
I cannot equate term$ to anything and get the query to recognize
wildcards.
For example, if term$ = "*M*", I want the query to return MSFT, MMM,
MCD, etc.
Any ideas?
Thank you.
---
Allen
Comment