Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q286245

↑ Back to the top


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.

↑ Back to the top


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				

↑ Back to the top


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				

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


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					

Steps to Reproduce the Behavior

  1. Use the DRDA_VB ADO sample that comes with the SNA/Host Integration Server SDK. By default, this sample uses a server-side cursor.
  2. Run the sample and connect to your DB2.
  3. Open a Recordset with a SELECT statement that resembles the following:
    SELECT * FROM SCHEMANAME.TABLENAME					
  4. Click the Edit button and change some values.
  5. Click the Update button. You receive the error that is listed in the "Symptoms" section of this article.

↑ Back to the top


References

For additional information about DB2OLEDB and cursors, click the following article numbers to view the articles in the Microsoft Knowledge Base:
269597� PRB: Limitations of ADO Client Cursor and Data-Bound Controls with DB2OLEDB
271131� Use the DRDA_VB Sample for DB2OLEDB
218590� INF: Configuring Data Sources for the Microsoft OLE DB Provider for DB2
216810� Creating Packages for Use with ODBC Driver for DB2 and OLE DB Provider for DB2
269626� INFO: Permissions Needed to Create Packages Using DB2OLEDB on DB2 and DB2/400

↑ Back to the top


Keywords: kb3rdparty, kbdb2, kbdriver, kbprb, kbprovider, KB286245

↑ Back to the top

Article Info
Article ID : 286245
Revision : 4
Created on : 2/16/2004
Published on : 2/16/2004
Exists online : False
Views : 311