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

Error Using SQL Statements in ADODC's

Status
Not open for further replies.

chamira

Programmer
Apr 17, 2001
6
US
I am trying to display data from an Access database using ADO Data Controls and the DataCombo + DataGrid controls. In the ADODC properties box, I setup up the following:

ConnectionString: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\anyDB.mdb;
RecordSource: SELECT * FROM Customers WHERE LastName = 'Smith'

My problem is that I always get the error: "Syntax Error in WHERE clause". When I change the RecordSource to the following:"SELECT * FROM Customers WHERE Age = 22", it works. So for some reason, it doesn't work only when I have text in the WHERE clause. Can anyone tell me how to correct this error. Thanks,

Chamira.
 
try changeing the single 'smith' quote to a double quote "smith".
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Hi Doug, thanks for your reply. I did try changing the single quotes to double quotes, but that didn't work. However, I was able to solve the problem. The problem was in the sql statement - I had to specify the table name in the WHERE clause:

RecordSource: SELECT * FROM Customers WHERE Customers.LastName = 'Smith'

It doesn't make sense because I only specified one table in the statement, but at least it works.

Chamira.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top