Monday, December 10, 2007

Operation must use an updateable query

It might be sometime you will got this error when working with ASP.NET and Ms. Access database.
System.Data.OleDb.OleDbException: Operation must use an updateable query. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at Register.ExecuteCommand(String MyCmd) in d:\Project\fake\UserManagement\Register.aspx.cs:line 60
The error would be different depending on your ASP.NET code. But the main error will looks similar.
This is very well known problem and may occur under the following circumstances
  • An ASP.NET worker process (Aspnet_wp.exe) runs under the default ASPNET account.
  • You do not enable impersonation on that application.
  • You try to connect to or write to an Access database.
To solve the problem you need to give the permission to ASPNET account. The exact permissions are Modify. Although on Windows Server 2003, it is probably the NETWORK SERVICE account.
  1. Right click on the folder containing the Access database, then choose Properties | Security.
  2. Click "Add".
  3. Click "Advanced" and make sure the "From this location..." entry matches the current box.
  4. Click "Find Now" and you will be presented with a list of user accounts.
  5. Double click the NETWORK SERVICE entry, then click OK.
  6. Select the "Modify" option, then click "Apply".
The image shown below illustrated the process.

Hope this helps.

Reference :

No comments: