Access SQL syntax error when using OleDbCommandBuilder

二次信任 提交于 2019-11-27 09:10:18

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.)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!