By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"mp" <pl****@volja.net> wrote in message
news:OH****************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #2

P: n/a
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

"mp" <pl****@volja.net> wrote in message
news:OH****************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.