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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with "Like" Query in ADO

Status
Not open for further replies.

CodeHammer

Programmer
Jun 5, 2002
8
US
The following query:

select * from customer where displayname like '*farm*'

works perfectly when used inside Access. It returns 44 records. However when the following code is executed

SQL$ = "select * from customer where displayname like '*farm*'"
Set clsadoRec = clsadoCon.Execute(SQL$)

t% = 0

If Not clsadoRec.BOF And Not clsadoRec.EOF Then
While Not clsadoRec.EOF
t% = t% + 1
clsadoRec.MoveNext
Wend
End If
CustomerCount = t%
clsadoRec.Close

Does not work. It returns 0 records. All connections to the DB are open correctly. In fact, this same code works properly when the "LIKE" keyword is not used in the SQL statement. Anyone got any ideas?
 
Check thread701-557100 and see if the information helps, otherwise, post back with information about the connection and recordset object etc..
 
Access SQL is not ansi compliant. Use % instead of * for multiple character matches.
 
Thanks guys. It was the wildcard that was the problem. I was using * instead of %.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top