HasRows
このプロパティは、OracleDataReaderに1つ以上の行があるかどうかを示します。
宣言
// C#
public override bool HasRows {get;}戻り値
bool
備考
HasRowsは、OracleDataReaderに行が含まれているかどうかを示します
HasRowsの値が行の位置に基づいて変わることはありません。たとえば、アプリケーションで結果セットから行をすべて読み取り、次のReadメソッドの起動によりFalseが戻される場合でも、結果セットが最初から空であったわけではないので、HasRowsプロパティはTrueを戻します。
OracleDataReaderオブジェクトの作成後にHasRowsプロパティが初めてアクセスされたときに、行がフェッチされ、OracleDataReaderが空かどうかが判断されます。
例
// C#
using System;
using Oracle.DataAccess.Client;
class HasRowsSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleCommand cmd = new OracleCommand(
"select * from emp where empno = 9999", con);
OracleDataReader reader = cmd.ExecuteReader();
if (!reader.HasRows)
Console.WriteLine("The result set is empty.");
else
Console.WriteLine("The result set is not empty.");
con.Dispose();
}
}
関連項目:
-
Oracle.DataAccess.ClientおよびOracle.ManagedDataAccess.Clientのネームスペース
-
このMicrosoft .NET Framework 機能の詳細は、
http://msdn.microsoft.com/libraryを参照