0

I am developing a website.

My connection string in web.config is as below:

"add name="MyDbConn1" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\QWIN 2000Q\Database\qwin_5501q.mdb;""

I already retrieve several times from that database using that connection string. They are working.

But When I insert into a table, error pop ups that "syntax error in INSERT INTO statement".

The below is my codes for insert into statement.

command2.Parameters.AddWithValue("@Name", txtUser.Text);
command2.Parameters.AddWithValue("@Password", txtPwd.Text);
command2.Parameters.AddWithValue("@Role", ddlAccess.SelectedItem.ToString());
string abc = "Insert into Report_User (Name, Password, Role) VALUES (@Name,@Password,@Role);";

When I run that statement in the Microsoft Access, there is no error.

Anyone?

Is there any folder sharing permission or some sort??

1
  • Try doing an insert without parameters first. One of your parameters is probably invalid. so try string abc = "Insert into Report_User (Name, Password, Role) VALUES ('testName','testPassword,'testRole');"; Commented Dec 3, 2010 at 8:27

1 Answer 1

3

Replace SQL paramter names a la @Name with OleDB-specific parameter placeholder ?

Insert into Report_User (Name, Password, Role) VALUES (?, ?, ?);

change command2.Parameters.Add(..) accordingly.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually it is the "Password". I change to "Pwd" then it is OK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.