DB2 Version 10.1 for Linux, UNIX, and Windows

DB2ResultSet Class

The DB2ResultSet class provides the ability to scroll through a bindable stream of rows that are returned from a database. You can also insert, update, and delete rows in the DB2ResultSet object.

Namespace:
IBM.DataDB2
Assembly:
IBM.DataDB2 (in IBM.DataDB2.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

The scrollable DB2ResultSet class is supported on database servers that support scrollable cursors. Scrollable cursors are supported on the following database servers:
  • DB2® for Linux, UNIX, and Windows servers
  • DB2 for z/OS® servers, with the DB2 Connect™ license.
  • Informix® database server.

The scrollable DB2ResultSet class with dynamic cursor is only supported on database servers that support the dynamic cursor.

If you create a DB2ResultSet object with the DB2CursorType or DB2ResultSetOptions enumeration settings that the database server does not support, the IBM® Data Server Provider for .NET downgrades the DB2CursorType enumeration to the highest DB2CursorType enumeration level that the database server supports. The cursor type and other options of the DB2ResultSet object can be determined with the following properties:
  • CursorType
  • Scrollable
  • Updatable
  • Sensitive
  • SkipDeleted

Remarks

The DB2ResultSet class is used to access streams of rows that are generated from executing a statement. The DB2ResultSet class provides a flexible alternative to using the DB2DataReader class for reading data from a database server. Use of the DB2ResultSet class provides a high-performance alternative to using a DataSet with the DB2DataAdapter class for the binding of application controls to a database server.

Creating a DB2ResultSet object is similar to creating a DB2DataAdapter object: from a connected DB2Command object, the DB2Command.ExecuteResultSet method returns a DB2ResultSet object. You can call the DB2Command.ExecuteResultSet method with specific option to determine the properties of a DB2ResultSet object.

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.