DB2 Version 10.1 for Linux, UNIX, and Windows

DB2Command.ExecuteRow Method

Sends CommandText to the Connection and builds a DB2Record. This method is intended for result sets with a single row.

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

Syntax

[Visual Basic]
Public Function ExecuteRow () As DB2Record
[C#]
public DB2Record ExecuteRow()
[C++]
public:
DB2Record ExecuteRow ()
[JScript]
public function ExecuteRow () : DB2Record

Return value

A DB2Record instance representing the first (or only) row of a result set.

Example

[C#] The following example demonstrates how to create a DB2Record and read its column data.

[C#]
  public static string getSalesData(DB2Connection conn)
  {
    string salesQuery = "SELECT MAX(SALES) FROM SALES";
    string salesData = "";
    DB2Command cmd = new DB2Command(salesQuery, conn);
    DB2Record salesRec = cmd.ExecuteRow();

    salesData = salesRec.GetDB2Int32(0).ToString();

    return salesData;
  }

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.7
.NET Framework version
Supported in: 2.0, 3.0, 3.5 and 4.0
IBM Data Server Client
Supported in: IBM DB2 Version 9