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

SQL Help

Status
Not open for further replies.

jtgurkin

Technical User
Sep 16, 2002
47
US
I am trying to connect to an access database with the following SQL String...
Code:
strSQL = "SELECT * FROM Addresses WHERE Years Like *2005* ORDER BY LastName ASC, FirstName ASC, MiddleName ASC"
And I am getting the following error
Code:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'Years Like *2005*'.
/apprenticeship/ApWeb/dbconnect.asp, line 8

can someone please help?
 
you need to single qoutes around the *2003*

ie
strSQL = "SELECT * FROM Addresses WHERE Years Like '*2005*' ORDER BY LastName ASC, FirstName ASC, MiddleName ASC"

Also you don't need to put the ASC after the things you want to order by because SQL default Ascending in ORDER BY:

So use the following SELECT statement and you should not have any problems:

SELECT * FROM Addresses WHERE Years Like '*2005*' ORDER BY LastName, FirstName, MiddleName

and if you are going to a SQL database or Oracle database the wildcard characters are % instead of *.


 
OK I put the single quotes and now I'm getting an empty recordset and i know there are records that fit the criteria.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top