DB2 10.5 for Linux, UNIX, and Windows

DB2Command.ExecuteResultSet(System.Data.CommandBehavior, IBM®.Data.DB2.DB2CursorType) Method

Sends the CommandText to the Connection and builds a DB2ResultSet while specifing CommandBehavior and a DB2CursorType.

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

Syntax

[Visual Basic]
Public Function ExecuteResultSet( _
   ByVal behavior As CommandBehavior, _
   cursorType As DB2CursorType _
) As DB2ResultSet

[C#]
public DB2ResultSet
 ExecuteResultSet(
   CommandBehavior behavior,
   DB2CursorType cursorType
);
[C++]
public: DB2ResultSet
* ExecuteResultSet(
   CommandBehavior behavior,
   DB2CursorType cursorType
);
[JScript]
public function ExecuteResultSet(
   behavior : CommandBehavior,
   cursorType : DB2CursorType
) : DB2ResultSet
;

Parameters

behavior
One of the System.Data.CommandBehavior values.
cursorType
One of the IBM.Data.DB2.DB2CursorType values.

Return value

A DB2ResultSet instance.

Example

[C#] The following example demonstrates how to read data from a scrollable DB2ResultSet.

[C#]
  public static string getSalesData(DB2Connection conn)
  {
    string salesQuery = "SELECT * FROM SALES";
    string salesData = "";
    DB2Command cmd = new DB2Command(salesQuery, conn);
    DB2ResultSet salesRS = cmd.ExecuteResultSet(
      CommandBehavior.CloseConnection,
      DB2CursorType.Keyset);

    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;
  }