Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends,

i developed one of my application and i created a setup file along with MSaccess db file .

after i install the application while saving the data into the Ms access file it showing an error

"Operation must use an updateable query."

near the cmd.executenonquery();


here is the connection string :
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=phonebook.accdb;Persist Security Info=False");


please help me out of this.

thanking you.
Posted
Comments
OriginalGriff 3-Apr-14 6:49am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps if you show us the code that generates the problem, it might help?
Use the "Improve question" widget to edit your question and provide better information.

1 solution

OleDbCommand.ExecuteNonQuery Method [^] executes an SQL statement and returns the number of rows affected. So, if you use other than INSERT, UPDATE, DELETE sql statement, you need to use: OleDbCommand.ExecuteReader Method[^] or OleDbCommand.ExecuteScalar Method[^]

If you want more details, please provide the body of query.

On the other hand, please see this: Solving the Operation Must Use An Updateable Query error[^]
 
Share this answer
 
Comments
Mr.VJ 4-Apr-14 2:21am    
still getting the same error :(
Maciej Los 4-Apr-14 2:24am    
As i mentioned: If you want more details, please provide the body of query.
Mr.VJ 4-Apr-14 4:32am    
getting error near executenonquery.

OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=phonebook.accdb");
OleDbCommand cmdd = new OleDbCommand();



cmdd = new OleDbCommand();
cmdd.CommandText = "INSERT into login([image],[imagename],[name],[username],[email],[password],[mobile],[gender],[dob],[question],[answer]) VALUES(@image,@imagename,@name,@username,@email,@password,@mobile,@gender,@dob,@question,@answer)";
cmdd.Connection = conn;

cmdd.Parameters.AddWithValue("@image", imgByteArr);
cmdd.Parameters.AddWithValue("@imagename", imgname);
cmdd.Parameters.AddWithValue("@name", textBoxname.Text);
cmdd.Parameters.AddWithValue("@username", textBoxuser.Text);
cmdd.Parameters.AddWithValue("@email", textBoxemail.Text);
cmdd.Parameters.AddWithValue("@password", textBoxretype.Text);
cmdd.Parameters.AddWithValue("@mobile", textBoxmobile.Text);
cmdd.Parameters.AddWithValue("@gender", radio);
cmdd.Parameters.AddWithValue("@dob", dat);
cmdd.Parameters.AddWithValue("@question", comboBox1.Text);
cmdd.Parameters.AddWithValue("@answer", textBoxanswer.Text);
conn.Open();
cmdd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("inserted sucessfully","confirmation");

MainWindow main = new MainWindow();
main.Show();
this.Close();
Mr.VJ 4-Apr-14 4:34am    
this code works in visual studio... but after making a setup .exe , it doesnt work

getting error Operation must use an updateable query .. near executenonquery();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900