OleDb & ASP.NET - Exception - Operation must use an updateable query

M

mp

Hi,

I have following problem:

Operation must use an updateable query

I have use OleDb, C# and ASP.NET and MS Access DB named pubs.

Code:

private void Button1_Click(object sender, System.EventArgs e)
{
@OleDbConnection thisConnection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=" +
@"C:\base\pubs.mdb");

String insertCmd = "insert into Authors (au_id, au_lname) values (@Id,
@LName)";

OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);
myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar,
11));
myCommand.Parameters["@Id"].Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
40));
myCommand.Parameters["@LName"].Value = txtLName.Text; /*
Server.HtmlEncode(txtLName.Text); */
myCommand.Connection.Open();

//myCommand.ExecuteNonQuery();
try
{
myCommand.ExecuteNonQuery();
}
catch (OleDbException xx)
{
// Exception
lblMessage.Text = "Insert Data Failed - " + xx.Message;
}
myCommand.Connection.Close();
}

Thanks
 
M

mp

Hi,

I have put this example on web and everything works but localy doesn't.

Do you have ideas why does not work locally?

Thanks,

Mirko
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top