Question Why is this returning syntax error

acidflash

Active member
Joined
Oct 23, 2008
Messages
29
Programming Experience
1-3
Hello

I have a line of code that is strangely returning a syntax error? it is the following

"INSERT INTO TableName (Product, Quantity, Date, Price) VALUES ('test', '3', '11/5/2008', '1')

From where im standing the string seems to be fine, any ideas?

this is the error output

Could not insert into the table
INSERT INTO MaherTestCompanySUPBill (Product, Quantity, Date, Price) VALUES ('test', '3', '11/5/2008', '1')
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

plz help, any help is much appreciated.

acidflash
 
Ok I figured it out,

its right but the syntax error is because the column name is a keyword, and the database is getting confused, fixed it, named column "TheDate" instead of "Date" and worked fine, thanks everyone.

acidflash
 
Back
Top