• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Operation must use an updateable query


I have polls on my website that use databases.
When I view the pages on my hard disk I get this error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

I also uninstalled IIS and reinstalled it again. It worked the first time. Then I don't recall what
I did and it now gives me the same error.

I have been to Microsoft's Knowledge base (Article Q175168) but that has not been of any help.
I have also been to aspfaq.com where I found that you need to set write permissions on the folder that contains the database before you actually put the database in it. I tried that too and it did not work.

Please help.

1 Solution
What is your Query looks like?
You could be doing something like..

Call cn.Execute("Select * from TableName")

Instead of
Set rs = cn.Execute("Select * from TableName")

Does that make sense?
This error is typically encountered when your ASP script attempts to perform an UPDATE or some other action that alters the information in the database. This error occurs because ADO is unable to write to the database for one of the following reasons:

The most common reason is that the Internet Guest account (IUSR_MACHINE) does not have Write permissions on the database file (.mdb). To fix this problem, use the Security tab in Explorer to adjust the properties for this file so that the Internet Guest account has the correct permissions. NOTE: When using Microsoft Access databases with ADO, it is also necessary to give the Internet Guest account Write permissions on the directory containing the .mdb file. This is because Jet creates an .ldb file to handle database locking.

If you get this error and your site is hosted by someone else like an ISP you can fix it yourself in some situations. First try to find a CGI-BIN directory and place your database in their. ISP's normally give the CGI-BIN folder read/write access rights and you can use these so that your database is able to write.

So how do you setup your ADO conenction string to work in the CGI-BIN folder?

Set oConn = Server.CreateObject ("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/cgi-bin/MyFile.mdb")

A second cause of this error is that the database was not opened with the correct MODE for writing. If you perform the Open on the Connection object, you use the Mode property to indicate the permissions on the connection as shown here:

      SQL = "UPDATE Products Set UnitPrice = 2;"
      Set Conn = Server.CreateObject("ADODB.Connection")
      Conn.Mode = 3      '3 = adModeReadWrite
      Conn.Open "myDSN"
NOTE: By default, the MODE is set to 0(adModeUnknown), which generally allows updates.

Another cause of this error is that the "Read Only" setting may be checked in the Options page for this DSN in the ODBC Manager if you are using an ODBC DSN.

The last issue and work around pertains to any SQL data source. The error can be caused by SQL statements that violate referential integrity of the database. Here are a few of the most common queries that fail:

The simplest group to deal with are those you cannot change: crosstab, SQL pass-through, union, or update (or make-table) action queries that have UniqueValue properties set to Yes.

Another very common cause is when the join includes linked ODBC tables that do not have unique indexes. In this case, there is no way for SQL to guarantee that records are unique in a table that has fields whose value will change with the query.

One cause does have a robust workaround. If you try to update a join field on the "one" side of a "one-to-many" query it will fail unless you turn on cascading updates. This way, you delegate referential integrity to the JET engine.
post your code...

you probably try to update an readonly Recordset....
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Using Access ?
Need to setup security on the mdb file. Go to Windows explorer, choose your mdb, r-click to properties, security. Make sure the user IUSR_{yourservername} has ful access.
Your web pages are by default accessed by an user named IUSR_{yourservername}
>It worked the first time. Then I don't recall what I did and it now gives me the same error.

Did you add ";" character at the end of your sql statement?
Permissions, permissions, permissions...

Husain, you didn't read your previous Q comments from the experts...
Michel SakrCommented:
cgoldfarb  posted the correct solution for you.. this is a typical error in access databases on hosted sites..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now