473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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
2 2592
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: ano1optimist | last post by:
I have been running these queries in Access 2000 with no problems. This week, I had to install Access 2003 to create some runtime versions for another application, and now I keep getting "operation...
1
by: mp | last post by:
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:
2
by: mp | last post by:
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:
11
by: Arpan | last post by:
I have always been working with SQL Server 2005 for ASP.NET apps but due to some reasons, had to revert back to MS-Access 2000. When I try to insert/update a MS-Access DB table (MDB), ASP.NET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.