Help with Syntax using SQL Statement with Like and wildcards

M

Michael Turner

Hi

Can anyone help me with my syntax please. This is not working.
Set rs = conn.Execute("SELECT * FROM tblCompany WHERE company like '*" &
txt_search & "*';")

Thanks in advance

Mick
 
G

GVaught

Here is how Access returns the query:
.... FROM tblCustomers
WHERE (((tblCustomers.CompanyName) Like "*Enterprise*"));

From your code snippet, I am assuming you are using ASP.
Your code should read something similar to above, except add the & where
needed.
 
G

GVaught

Assuming ASP

Another test you can do is create a variable called strSQL and set it equal
to your SQL statement and then pass the variable name to the
conn.Execute(strSQL)

Doing this will allow you to run a Response.Write strSQL and Response.End
just before your conn.Execute to see what and how a value is being passed.
Once your SQL statement looks correct just place single quotes in front of
the two Response statements or delete them if everything works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top