Fixing the ASP.NET and Access "Operation must use an updateable query" error

Posted: (EET/GMT+2)

 

You've written a simple ASP.NET 2.0 application with C# that uses an Microsoft Access database through the usual ADO.NET OLEDB drivers. Your .MDB database is in the App_Data special folder, and you have copied your web application to a Windows Server 2003 computer. Your application works fine on the first look, but fails with the error message "Operation must use an updateable query." when you try to update your database for example with an SQL UPDATE or INSERT statement. What the heck?

Well, if you've been working with latest Microsoft platforms, you will soon guess that this is some kind of security problem, and indeed it is. So how do you fix this error?

To get rid of the error, you need to give more permissions to your App_Data special directory. The easiest way to do this is to launch the Internet Information Services Manager for your IIS 6.0 installation. Then, browse to your web site and the correct App_Data directory, right-click it and choose Permissions. You will see the following dialog box:

Since by default in Windows Server 2003 your ASP.NET worker process will run as a NETWORK SERVICE, you need to give this group both read and write rights to the directory (and thus the .MDB database file as well). That's it.

Oh, Microsoft Knowledge Base has an article with ID 175168 that also discusses this problem.