DB2 10.5 for Linux, UNIX, and Windows

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

Sends the CommandText to the Connection and builds a DB2ResultSet while specifing CommandBehavior, DB2ResultSetOptions, and a value determining if the operation will be aborted should the cursor be downgraded.

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

Syntax

[Visual Basic]
Public Function ExecuteResultSet( _
   ByVal behavior As CommandBehavior, _
   options As DB2ResultSetOptions, _
   abortOnOptValueChg As Boolean _
) As DB2ResultSet

[C#]
public DB2ResultSet
 ExecuteResultSet(
   CommandBehavior behavior,
   DB2ResultSetOptions options,
   bool abortOnOptValueChg
);
[C++]
public: DB2ResultSet
* ExecuteResultSet(
   CommandBehavior behavior,
   DB2ResultSetOptions options,
   bool abortOnOptValueChg
);
[JScript]
public function ExecuteResultSet(
   behavior : CommandBehavior,
   options : DB2ResultSetOptions,
   abortOnOptValueChg : Boolean
) : DB2ResultSet
;

Parameters

behavior
One of the System.Data.CommandBehavior values.
options
One of the IBM.Data.DB2.DB2ResultSetOptions values.
abortOnOptValueChg
A boolean value indicating whether to throw an exception if the cursor type was downgraded (true), or to allow the cursor to read the result set without throwing an exception (false).

Return value

A DB2ResultSet instance.

Example

[C#] The following example demonstrates how to read data from a scrollable DB2ResultSet. For database connections against a DB2® for Linux, UNIX, Windows data server, this code will throw an exception when the DB2ResultSet cursor reads data. This is because a value of true was passed to the abortOnOptValueChg parameter.

[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,
      DB2ResultSetOptions.Scrollable |
      DB2ResultSetOptions.Sensitive |
      DB2ResultSetOptions.SkipDeleted |
      DB2ResultSetOptions.Updatable,
      true);

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