Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Error : "Operation must use an updateable query"

  Asked By: Brayden    Date: Jun 11    Category: Asp.net    Views: 3782
  

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

Share: 

 

9 Answers Found

 
Answer #1    Answered By: Giovanna Silva     Answered On: Jun 11

are you sure you have only one field in the database table.

 
Answer #2    Answered By: Aaliyah Khan     Answered On: Jun 11

I added another field and changed the SQL statement to

string sqlStatement = "INSERT INTO TEST (TESTID, TESTROW) VALUES
(1, 'Testing')";

 
Answer #3    Answered By: Maurice Hanson     Answered On: Jun 11

Make sure the MDB(or the folder it's in) is not set to ReadOnly.

 
Answer #4    Answered By: Bellona Lopez     Answered On: Jun 11

Have you tried putting the database field explicitly into you query:

string sqlStatement = "INSERT INTO TEST (TestValue) VALUES ('Testing')";

just a thought.

 
Answer #5    Answered By: Jonathan Harrison     Answered On: Jun 11

Yes but still it gives the same error............

 
Answer #6    Answered By: Gerald Cruz     Answered On: Jun 11

Right click the directory the mdb  is in, choose properties, security, and
add the ASPNET user with write  permissions.

 
Answer #7    Answered By: Zoar Mizrachi     Answered On: Jun 11

There is no Security tab. I tried in IIS - default web  site also.
I cannot find a security tab.

 
Answer #8    Answered By: Eileen Carr     Answered On: Jun 11

Open up Windows Explorer, Tools Menu, Second Tab, uncheck the last option
about simple file  sharing. That will unhide the security tab.

 
Answer #9    Answered By: Phoebe Brown     Answered On: Jun 11

Now I can see the security tab.
Actually, the problem was solved after changing the username in Machine.config
file under <processmodel>.

 
Didn't find what you were looking for? Find more on Error : "Operation must use an updateable query" Or get search suggestion and latest updates.




Tagged: