BeanSoftware Logo

ASP.NET Database Search Control

    Write For Us

Solve Operation Must Use an Updateable Query Error in Access

MS Access database can be used as data storage of dynamic web sites. Sometimes, when you try to update existing or add new records, you will receive the "Operation must use an updateable query" error. Error details could be like this:

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.

This error description is not very useful, because if you look to your SQL query it is probably correct. The reason for this error is usually one of few reasons:

Web application has not write permission in folder where MS Access database is located

To update records, you need to write changes to .mdb file on disk. If your web application can't write to disk, you can't update existing or add new records. So, enable read/write access in database folder or move database to other folder where your application has write permission.

Database file has ReadOnly attribute

If .mdb file is Read Only, then you can't write to it. So, to enable updating and inserting of records you need to remove ReadOnly attribute. You can do that in Windows explorer. Locate the .mdb file (or .accdb file if you use newer version of MS Access), right click to it and select properties. Uncheck ReadOnly check box, like on image bellow.

Removing ReadOnly attribute on MS Access database

You already have other database connection opened

Always disconnect from database after you execute needed queries. If your database remains exclusively opened (e.g. if you open database at application level or in separated thread and garbage collector is still not destroyed a connection) you can't open another connection and change records. So, check your code to see are you disconnected from database every time before try to execute new SQL queries.

In case that you don't want to disconnect from database because of some reason, then consider to use the same connection instead of creating new one.

I hope this tutorial was helpful and saved your time especially if you have short deadline :). Happy coding!

Related articles:

1. Connecting ASP.NET to Access and SQL Server Database

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback

Copyright © 2002-2008 Bean Software. All rights reserved.