Microsoft KB Archive/286245

= PRB: Error Updating Records Using DB2OLEDB and Server-Side ADO Cursor =

Article ID: 286245

Article Last Modified on 2/16/2004

-

APPLIES TO


 * Microsoft OLE DB Provider for DB2
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6
 * Microsoft Host Integration Server 2000 Standard Edition
 * Microsoft SNA Server 4.0 Service Pack 3
 * Microsoft SNA Server 4.0 Service Pack 4

-



This article was previously published under Q286245



SYMPTOMS
When you use an ActiveX Data Objects (ADO) server-side cursor with the Microsoft OLE DB Provider for DB2 (DB2OLEDB) that comes with Host Integration Server or with SNA Server 4.0 SP3 or SP4, the following error may occur when you try to update a recordset:

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.



CAUSE
You have not included the FOR UPDATE option in your SQL statement. For example, you may have opened the ADO Recordset with a SELECT statement like the following: SELECT * FROM SCHEMANAME.TABLENAME



RESOLUTION
To allow updates to an ADO Recordset with the DB2OLEDB provider and a server-side cursor, you must use the FOR UPDATE option; for example: SELECT * FROM SCHEMANAME.TABLENAME FOR UPDATE



STATUS
This behavior is by design.



MORE INFORMATION
 Starting with SNA Server 4.0 SP3, DB2OLEDB supports updateable Recordset objects either through an ADO client-side cursor or through a server-side cursor. If you are using a client-side cursor, you do not need to use the FOR UPDATE clause in the SELECT statement. However, if you are using a server-side cursor, this clause is required. If you use Microsoft OLE DB Provider for ODBC Drivers (MSDASQL) and the Microsoft ODBC Driver for DB2, you do not need to use the FOR UPDATE clause in the SELECT statement. The FOR UPDATE clause is only required when you are directly using the DB2OLEDB provider with a server-side ADO cursor and you are trying to update a record. FOR UPDATE is not required if you are trying to insert a new record.  When connecting to DB2 for MVS V4R1, V5R1, or V6R1 and DB2 for OS/400 V3R2, there are further requirements to indicate the columns that you intend to update. For example, to update the COL1_NAME and COL2_NAME columns in the SCHEMANAME.TABLENAME table, the following SQL syntax must be used: SELECT * FROM SCHEMANAME.TABLENAME FOR UPDATE OF COL1_NAME, COL2_NAME                </li></ul>

Steps to Reproduce the Behavior
<ol> Use the DRDA_VB ADO sample that comes with the SNA/Host Integration Server SDK. By default, this sample uses a server-side cursor.</li> Run the sample and connect to your DB2.</li>  Open a Recordset with a SELECT statement that resembles the following: SELECT * FROM SCHEMANAME.TABLENAME                   </li> Click the Edit button and change some values.</li> Click the Update button. You receive the error that is listed in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">