DB2®Command.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;
  }