When I use ExecuteNonQuery method I get an error as
[OleDbException (0x80004005): Operation must use an updateable
query.]
The same code was working fine with Visual Studio.NET Beta 2
version. It does
not work at all with later versions.
Could anyone please let me know how to solve this problem
CODE USED:
private void Page_Load(object sender, System.EventArgs e)
{
string m_connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\inetpub\\wwwroot\\SOnet\\lso.MDB";
string sqlStatement = "INSERT INTO TEST VALUES ('Testing')";
int retVal;
System.Data.OleDb.OleDbConnection conn =
new System.Data.OleDb.OleDbConnection
(m_connString);
System.Data.OleDb.OleDbCommand comm = new
System.Data.OleDb.OleDbCommand();
conn.Open();
comm.Connection = conn;
comm.CommandType = System.Data.CommandType.Text;
comm.CommandText = sqlStatement;
retVal = comm.ExecuteNonQuery ();
Response.Write (retVal.ToString());
conn.Close();
}
COMPLETE ERROR MESSAGE:
Server Error in '/SOnet' Application.
Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Operation must
use an updateable query.
Source Error:
Line 36: comm.CommandText = sqlStatement;
Line 37:
Line 38: retVal = comm.ExecuteNonQuery ();
Line 39:
Line 40: Response.Write (retVal.ToString());
Source File: c:\inetpub\wwwroot\sonet\webform1.aspx.cs Line: 38
Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable
query.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling
(Int32 hr)
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult
(tagDBPARAMS dbParams, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal
(CommandBehavior behavior, String method)
System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
SOnet.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\sonet\webform1.aspx.cs:38
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724