Raj
Raj

Reputation: 361

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

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

Upvotes: 1

Views: 915

Answers (1)

Fionnuala
Fionnuala

Reputation: 91376

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

Upvotes: 2

Related Questions