Help with Syntax using SQL Statement with Like and wildcards

  • Thread starter Thread starter Michael Turner
  • Start date Start date
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
 
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.
 
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.
 
Back
Top