Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All, When i update msaccess file the error comes:


Operation must use an updateable query.

code is
C#
string strSQL = "Update Account set OBAL_AM=(select top 1 OBAL_AM from  Account where Acct_Cd='" + TextBox1.Text + "' and Code_No='" + brcod + "') where  Acct_Cd='" + TextBox2.Text + "'  and Code_No='" + brcod + "'";
            OleDbCommand cmd = new OleDbCommand(strSQL, myConn);
            myConn.Open();
            cmd.ExecuteNonQuery(); myConn.Close();
Posted
Updated 25-Jul-14 3:07am
v3
Comments
Sergey Alexandrovich Kryukov 25-Jul-14 9:06am    
"ASM" in the tags? Are you serious?
—SA
[no name] 25-Jul-14 9:08am    
Your database is probably set to be read-only.

The error message is so clear that, if you don't fully understand it, you should really read on relational databases and ADO.NET pretty much from scratch, to understand just the basic ideas.

If you are using ExecuteNonQuery, it means that your SQL statement is supposed to modify some data in the database, but your is a select statement, that is, a pure query. Isn't that obvious: you are using ExecuteNonQuery with a query.

With a query, you should use ExecuteReader or ExecuteScalar, to have something to obtain the query results: http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 

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