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

Like Statements

Status
Not open for further replies.

DirtyB

Programmer
Mar 13, 2001
159
US
I am having trouble getting a select query with a 'Like' in it, returning a recordset to ADO. What exactly is the syntax for Like statement in Access? I have been doing it like this: WHERE fieldname LIKE '*data*'

Here's the catch: I am running this through ASP. If I print out the query string that i'm sending to the database, and copy directly into Access, it works fine. It just can't populate the recordset.

Anyone know anything about this?
 
try this one. In many cases it is the same thing.
WHERE fieldname = '*data*' John Fill
1c.bmp


ivfmd@mail.md
 
i've tried about everything from:

LIKE '*variable*'
LIKE "*variable*"
LIKE "%variable%"
= '*variable*'
and many more

the thing is that the queries work if I cut and paste them into Access. And for some of the different things i've tried above, there are no error messages, but it treats my operator like an = sign. So it will only return EXACT matches.
 
This is how I do variables....

strSQL = strSQL & "WHERE fieldname LIKE %" & YourVar & "%"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top