Unable to fire update and insert query in access using C# windows application

别来无恙 提交于 2019-12-31 04:17:09

问题


I am trying to create one windows application with MS Access backend but I am facing some problems for insert and update query.

The select statement works fine for me, but insert and update are not working. The message is: syntax error in "update" and " insert into "

below is my connection string to connect access database

<add key="AppConnection" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GNDb.mdb;
  Jet OLEDB:Database Password=@black123;" ></add>

And Queries that I am trying to fire from front end to backend

Insert : insert into tblU(UserName, Password) values('ops1', 'ops')

Update : Update tblU set Password='pqr5' where UserName='pqr'

this is my table schema:

ID            - AutoNumber
UserName text - text
Password      - text

In Front end I use Oledb connection and command. I am using 2003 ms access mdb file. I do not know which kind of syntax error is this? Please suggest me the correction/Answer


回答1:


Password is a reserved word and should be enclosed in square brackets.

insert into tblU(UserName, [Password]) values('ops1', 'ops')

Reserved words in Jet and ACE



来源:https://stackoverflow.com/questions/11950729/unable-to-fire-update-and-insert-query-in-access-using-c-sharp-windows-applicati

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