I am trying to use an SQL command in my code but i am having trouble using WHERE & AND in the statement. I am using an OLEDB connection to a database.
The command text i am using is,
string commandText = "SELECT * FROM Table1 WHERE Date = " + selDate + " AND Location = " + selLocation + " AND Route = " + selRoute;
I just get an OLEDB Exception "Syntax error (missing operator) in query expression 'Date = 12/05/2008 00:00:00 AND Location = UK AND Route = 20'"
The command will run if i just use "SELECT * FROM Table1" but when i add a WHERE or AND i get exceptions.
I use this statement in the following: OleDbDataAdaptor adaptor = new OleDbDataAdaptor(commandText, conn)
How do i get the statement to work with WHERE & AND?
Many Thanks