Access SQL syntax error when using OleDbCommandBuilder

Try this:

Immediately after the line

var builder = new OleDbCommandBuilder(dbAdapter);

add the two lines

builder.QuotePrefix = "[";
builder.QuoteSuffix = "]";

That will tell the OleDbCommandBuilder to wrap table and column names in square brackets, producing an INSERT command like

INSERT INTO [TableName] ...

instead of the default form

INSERT INTO TableName ...

The square brackets are required if any table or column names contain spaces or “funny” characters, or if they happen to be reserved words in Access SQL. (In your case, I suspect that your table has a column named [Password], and PASSWORD is a reserved word in Access SQL.)

Leave a Comment

tech