Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used the code for Retrieving, Inserting, Updating and Deleting in following method
C#
protected void Button1_Click(object sender, EventArgs e)
{
  string conn = "ConnectionString";
  SqlConnection sqlcon = new SqlConnection(conn);
  sqlcon.Open();
  SqlCommand comm = new SqlCommand("Insert into table1 (field1,field2) values (@f1,@f2)", sqlcon);          //and retrieve, update,delete
  comm.Parameters.AddWithValue("f1", int.Parse(txtid.Text.ToString()));
  comm.Parameters.AddWithValue("f2", Txtname.Text.ToString());
  comm.ExecuteNonQuery();
}

It is running good in my development system i.e. Visual Studio Installed System...
(I am Developing windows application,,,)(Created setup file by deployment process)
but when i install this project into another system by setup created,
It is able to retrieve the data from database but not inserting, updating , deleting

I am getting the following error,
Unhandled exception had occured in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit the application will close immediately.

  Operation must use an Updatable Query.

I searched for the above error....
I found solution that to check the database property is set to Read Only..

But it is not set to Read Only

plz give me some solution
Posted
Updated 4-Feb-12 0:49am
v2
Comments
Martin Arapovic 4-Feb-12 7:02am    
Hm!!!
If your database is writable. Connect to it using SSMS tool and use sql user credentials that you are using through your code in ConnectionString and then try to insert something. If that is working then your code must work also...
This error remind me to old times when I was using access :) This is very strange that this error appears with sql server db if database is not read-only and user that is used can make changes to the database.

1 solution

One thing is to check that the database files (and the directory) are writable and account used by SQL Server has permissions to write to them.
 
Share this answer
 
Comments
muzaffar527 4-Feb-12 6:59am    
I am using MS-Access database...
and I checked the folder and .mdb file is not readonly...
Wendelius 4-Feb-12 7:07am    
Access, but you're using SqlConnection which is intended for SQL Server connections???
muzaffar527 8-Feb-12 5:42am    
plz give some solution... I have structed in this problem......
muzaffar527 4-Feb-12 7:29am    
Sorry... it is actually

string conn = "ConnectionString";
OleDbConnection cn = new OleDbConnection(conn);
cn.Open();
OleDbCommand comm = new OleDbCommand("Insert into table1 (field1,field2) values (@f1,@f2)", cn);
comm.Parameters.AddWithValue("f1", int.Parse(txtid.Text.ToString()));
comm.Parameters.AddWithValue("f2", Txtname.Text.ToString());
comm.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