Can someone please explain why, when I click the \"Commit\" button, I get the error
Syntax error in INSERT INTO statement.
Here\
Position
is a reserved word for JET 4.0 - try to rename the column something else such as prog_position
. Access will often let you create the column with a reserved name, but when you go to access it in code JET blocks it and gives you a generic Syntax error in INSERT INTO Statement
error without being specific. Check out http://support.microsoft.com/kb/248738 for more information on reserved words. It is goods practice to always prefix your column names with something short so that you never run into conflicts or reserved word issues.
As Makita mentions, your problem stems from the fact that Position
is a reserved word in Jet/ACE SQL. The solution is to add the following two lines of code after you create the OleDbCommandBuilder
object:
cb.QuotePrefix = "["
cb.QuoteSuffix = "]"
That will tell the OleDbCommandBuilder
to generate SQL statements like this
INSERT INTO [TA_OFFICER] ([FirstName], ...
...instead of
INSERT INTO TA_OFFICER (FirstName, ...
Wrapping the Position
column name in those square brackets will tell the Jet database engine that it is a column name, not a keyword.
This kind of error can happen when you have different data type in the code and in the DB. Checking the log can give some light on this.