DB2 V10.1 for Linux, UNIX, and Windows

DB2Command.ExecuteRow 方法

CommandText 发送至 Connection 并构建 DB2Record。此方法适用于包含单行的结果集。

名称空间:
IBM®.Data.DB2®
组合件:
IBM.Data.DB2(在 IBM.Data.DB2.dll 中)

语法

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

返回值

DB2Record 实例,表示结果集的第一行(或仅第一行)。

示例

[C#] 以下示例演示如何创建 DB2Record 并从中读取列数据。

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

版本信息

最近一次更新
本主题在 IBM DB2 V9.7 中进行了最近一次更新
.NET Framework 版本
支持版本:2.0、3.0、3.5 和 4.0
IBM 数据服务器客户机
支持版本:IBM DB2 V9