Microsoft KB Archive/175168: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 12: Line 12:
<div id="TitleRow">
<div id="TitleRow">


= <span id="KB175168"></span>ASP returns &quot;Operation must use an updateable query&quot; error =
= <span id="KB175168"></span>ASP returns "Operation must use an updateable query" error =




Line 78: Line 78:


<ol>
<ol>
<li>The most common reason is that the Internet Guest account (IUSR_MACHINE), which is by default part of the &quot;Everyone&quot; group, 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.<br />
<li>The most common reason is that the Internet Guest account (IUSR_MACHINE), which is by default part of the "Everyone" group, 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.<br />
<br />
<br />
'''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. You may also need to give read/write permission on the &quot;Temp&quot; folder because Jet may create temporary files in this directory.</li>
'''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. You may also need to give read/write permission on the "Temp" folder because Jet may create temporary files in this directory.</li>
<li><p>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:</p>
<li><p>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:</p>
<pre class="codesample">
<pre class="codesample">
       SQL = &quot;UPDATE Products Set UnitPrice = 2;&quot;
       SQL = "UPDATE Products Set UnitPrice = 2;"
       Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
       Set Conn = Server.CreateObject("ADODB.Connection")
       Conn.Mode = 3      '3 = adModeReadWrite
       Conn.Mode = 3      '3 = adModeReadWrite
       Conn.Open &quot;myDSN&quot;
       Conn.Open "myDSN"
       Conn.Execute(SQL)
       Conn.Execute(SQL)
       Conn.Close
       Conn.Close
Line 92: Line 92:
                         </pre>
                         </pre>
<p>'''NOTE''': By default, the MODE is set to 0(adModeUnknown), which generally allows updates.</p></li>
<p>'''NOTE''': By default, the MODE is set to 0(adModeUnknown), which generally allows updates.</p></li>
<li>Another cause of this error is that the &quot;Read Only&quot; setting may be checked in the Options page for this DSN in the ODBC Manager.</li>
<li>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.</li>
<li>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:<br />
<li>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:<br />


Line 102: Line 102:
<br />
<br />
</li>
</li>
<li>One cause does have a robust workaround. If you try to update a join field on the &quot;one&quot; side of a &quot;one-to-many&quot; query it will fail unless you turn on cascading updates. This way, you delegate referential integrity to the JET engine.</li></ul>
<li>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.</li></ul>
</li></ol>
</li></ol>



Latest revision as of 11:07, 21 July 2020

Knowledge Base


ASP returns "Operation must use an updateable query" error

Article ID: 175168

Article Last Modified on 1/23/2006



APPLIES TO

  • Microsoft Active Server Pages 4.0
  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Services 5.0
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7



This article was previously published under Q175168

SYMPTOMS

You may encounter the following common error when you use ActiveX Data Objects (ADO) with Active Server Pages (ASP):

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access 97 Driver] Operation must use an updateable query.

CAUSE

This article explains the four primary causes of this error and the corresponding workarounds. Although this article refers to Microsoft Access databases, the information provided here also applies to other types of databases.

RESOLUTION

This error is typically encountered when your 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:

  1. The most common reason is that the Internet Guest account (IUSR_MACHINE), which is by default part of the "Everyone" group, 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. You may also need to give read/write permission on the "Temp" folder because Jet may create temporary files in this directory.
  2. 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"
          Conn.Execute(SQL)
          Conn.Close
    
                            

    NOTE: By default, the MODE is set to 0(adModeUnknown), which generally allows updates.

  3. 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.
  4. 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 groups 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.


STATUS

This behavior is by design.

Keywords: kberrmsg kbdatabase kbprb KB175168