DB2 Version 9.7 for Linux, UNIX, and Windows

DB2ResultSet Class

Provides multi-directional scrolling through a bindable stream of data rows from a database. In addition, DB2ResultSet instances can also insert, update, and delete rows.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Inheritance hierarchy

System.Object
   System.MarshalByRefObject
      IBM.Data.DB2.DB2ResultSet

Syntax

[Visual Basic]
Public Class DB2ResultSet
[C#]
public class DB2ResultSet
[C++]
public class DB2ResultSet
[JScript]
public class DB2ResultSet

Data server restrictions

Scrollable DB2ResultSet instances are only supported when accessing data servers that support scrollable cursors. Currently this includes the following:
  • DB2® Database for Linux, UNIX, and Windows, Version 9.1, Version 9.5, Version 9.7, and Version 9.8
  • DB2 Universal Database™ for z/OS® Version 8, Version 9, and Version 10 , through DB2 Connect™
  • IBM® Informix®, Version 11.10, and Version 11.50

Scrollable DB2ResultSet instances using dynamic cursors are only supported when accessing data servers that support dynamic cursors. Currently this includes DB2 UDB for z/OS Version 8 and DB2 Version 9.1 for z/OS.

To access a scrollable cursor in a three-tier environment, the DB2 Connect gateway must be running DB2 UDB for Linux, UNIX, and Windows Version 8, or DB2 database for Linux, UNIX, and Windows Version 9.

If you create a DB2ResultSet instance using DB2CursorType or DB2ResultSetOptions settings that the data server does not support, the IBM Data Server Provider for .NET will downgrade the DB2ResultSet instance to the highest level that the data server will support. You can see the DB2ResultSet instance's cursor type and its other options by checking the following properties:
  • CursorType
  • Scrollable
  • Updatable
  • Sensitive
  • SkipDeleted

Remarks

The DB2ResultSet class enables you to deploy scrollable and updatable streams of data rows in your applications. This provides a flexible alternative to using a DB2DataReader for reading data from a data server. More significantly, this provides a high-performance alternative to using a DataSet with a DB2DataAdapter for the binding of application controls to a data server.

Creating a DB2ResultSet instance is similar to creating a DB2DataAdapter: from a connected DB2Command instance, the DB2Command.ExecuteResultSet method will return a DB2ResultSet. You can set various options in the DB2Command.ExecuteResultSet methods to determine the capabilities of a DB2ResultSet.

Restriction: If your application uses a DB2ResultSet instance with a static cursor, and fetches out of bounds it could bring down a DB2 UDB Version 8 data server. To avoid this situation, apply FixPak 13 to the DB2 UDB Version 8 data server.

Example

[C#] The following example demonstrates how to read data from a scrollable DB2ResultSet that is sensitive to inserts, updates, and deletes from other applications.

[C#]
  public static string getSalesData(DB2Connection conn)
  {
    string salesQuery = "SELECT * FROM SALES";
    string salesData = "";
    DB2Command cmd = new DB2Command(salesQuery, conn);
    DB2ResultSet salesRS = cmd.ExecuteResultSet(
      DB2ResultSetOptions.Scrollable |
      DB2ResultSetOptions.Sensitive |
      DB2ResultSetOptions.SkipDeleted);

    if (salesRS.Scrollable)
    {
      if (salesRS.ReadLast())
      {
        salesData = salesRS.GetDB2Date(0).ToString();
        salesData += ", " + salesRS.GetDB2String(1).ToString();
        salesData += ", " + salesRS.GetDB2String(2).ToString();
        salesData += ", " + salesRS.GetDB2Int32(3).ToString();
      }
    }

    return salesData;
  }

Thread safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.7 Fix Pack 5
.NET Framework version
Supported in: 2.0, 3.0, 3.5, and 4.0