OleDbDataReader クラス
定義
データ ソースからデータ行の前方向ストリームを読み取る方法を提供します。Provides a way of reading a forward-only stream of data rows from a data source. このクラスは継承できません。This class cannot be inherited.
public ref class OleDbDataReader sealed : System::Data::Common::DbDataReader
public sealed class OleDbDataReader : System.Data.Common.DbDataReader
type OleDbDataReader = class
inherit DbDataReader
Public NotInheritable Class OleDbDataReader
Inherits DbDataReader
- 継承
例
次の例ではOleDbConnection、、 OleDbCommand、およびOleDbDataReaderを作成します。The following example creates an OleDbConnection, an OleDbCommand, and an OleDbDataReader. この例では、データを読み取り、コンソールに書き込みます。The example reads through the data, writing it out to the console. 最後に、この例でOleDbDataReaderは、をOleDbConnection閉じてから、を閉じます。Finally, the example closes the OleDbDataReader and then the OleDbConnection.
public static void ReadData(string connectionString, string queryString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader[0].ToString());
}
reader.Close();
}
}
Public Sub ReadData(ByVal connectionString As String, _
ByVal queryString As String)
Using connection As New OleDbConnection(connectionString)
Dim command As New OleDbCommand(queryString, connection)
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
Console.WriteLine(reader(0).ToString())
End While
reader.Close()
End Using
End Sub
注釈
を作成OleDbDataReaderするには、コンストラクターを直接使用するOleDbCommandのではなく、オブジェクトのExecuteReaderメソッドを呼び出す必要があります。To create an OleDbDataReader, you must call the ExecuteReader method of the OleDbCommand object, instead of directly using a constructor.
を閉じるOleDbConnection前に、まずOleDbDataReaderオブジェクトを閉じます。Before you close the OleDbConnection, first close the OleDbDataReader object. また、 OleDbCommandオブジェクトを使用OleDbDataReaderする場合は、オブジェクトを閉じる必要があります。たとえば、を呼び出しCloseた後に出力パラメーターを取得することはできません。You must also close the OleDbDataReader object if you plan to resuse an OleDbCommand object.For example, you cannot retrieve output parameters until after you call Close.
データの読み取り中に別のプロセスまたはスレッドによって結果セットに加えられた変更は、 OleDbDataReaderのユーザーに表示されることがあります。Changes made to a result set by another process or thread while data is being read may be visible to the user of the OleDbDataReader. ただし、正確な動作はタイミングに依存します。However, the precise behavior is timing dependent.
IsClosedとRecordsAffectedは、 OleDbDataReaderが閉じられた後に呼び出すことができる唯一のプロパティです。IsClosed and RecordsAffected are the only properties that you can call after the OleDbDataReader is closed. がOleDbDataReader存在RecordsAffectedする間はプロパティにアクセスできますが、 Close正確な戻り値をRecordsAffected保証するには、の値を返す前に必ずを呼び出してください。Although the RecordsAffected property may be accessed while the OleDbDataReader exists, always call Close before returning the value of RecordsAffected to guarantee an accurate return value.
プロパティ
Depth |
現在の行の入れ子の深さを示す値を取得します。Gets a value that indicates the depth of nesting for the current row. |
FieldCount |
現在の行の列の数を取得します。Gets the number of columns in the current row. |
HasRows |
OleDbDataReader に 1 行以上の行が格納されているかどうかを示す値を取得します。Gets a value that indicates whether the OleDbDataReader contains one or more rows. |
IsClosed |
データ リーダーが閉じているかどうかを示します。Indicates whether the data reader is closed. |
Item[Int32] |
列の序数によって指定した列の値をネイティブ形式で取得します。Gets the value of the specified column in its native format given the column ordinal. |
Item[String] |
列名によって指定した列の値をネイティブ形式で取得します。Gets the value of the specified column in its native format given the column name. |
RecordsAffected |
SQL ステートメントの実行によって変更、挿入、または削除された行の数を取得します。Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. |
VisibleFieldCount |
OleDbDataReader 内の表示フィールドの数を取得します。Gets the number of fields in the OleDbDataReader that are not hidden. |
メソッド
Close() |
OleDbDataReader オブジェクトを閉じます。Closes the OleDbDataReader object. |
CreateObjRef(Type) |
リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (継承元 MarshalByRefObject) |
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判定します。Determines whether the specified object is equal to the current object. (継承元 Object) |
Finalize() |
オブジェクトがガベージ コレクションにより収集される前に、そのオブジェクトがリソースを解放し、その他のクリーンアップ操作を実行できるようにします。Allows the object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. |
GetBoolean(Int32) |
指定された列の値を Boolean として取得します。Gets the value of the specified column as a Boolean. |
GetByte(Int32) |
指定された列の値をバイトとして取得します。Gets the value of the specified column as a byte. |
GetBytes(Int32, Int64, Byte[], Int32, Int32) |
指定した列オフセットからのバイト ストリームを、配列としてバッファーに読み込みます。読み込みは、指定したバッファー オフセットから開始されます。Reads a stream of bytes from the specified column offset into the buffer as an array starting at the given buffer offset. |
GetChar(Int32) |
指定した列の値を文字として取得します。Gets the value of the specified column as a character. |
GetChars(Int32, Int64, Char[], Int32, Int32) |
指定した列オフセットからの文字ストリームを、配列としてバッファーに読み込みます。読み込みは、指定したバッファー オフセットから開始されます。Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. |
GetData(Int32) |
要求された列の序数の OleDbDataReader オブジェクトを返します。Returns an OleDbDataReader object for the requested column ordinal. |
GetDataTypeName(Int32) |
ソース データ型名を取得します。Gets the name of the source data type. |
GetDateTime(Int32) |
指定された列の値を DateTime オブジェクトとして取得します。Gets the value of the specified column as a DateTime object. |
GetDecimal(Int32) |
指定された列の値を Decimal オブジェクトとして取得します。Gets the value of the specified column as a Decimal object. |
GetDouble(Int32) |
指定した列の値を倍精度浮動小数点数として取得します。Gets the value of the specified column as a double-precision floating-point number. |
GetEnumerator() |
データ リーダー内の行に対して反復処理を行うために使用できる IEnumerator を返します。Returns an IEnumerator that can be used to iterate through the rows in the data reader. |
GetFieldType(Int32) |
オブジェクトのデータ型である Type を取得します。Gets the Type that is the data type of the object. |
GetFloat(Int32) |
指定した列の値を単精度浮動小数点数として取得します。Gets the value of the specified column as a single-precision floating-point number. |
GetGuid(Int32) |
指定した列の値をグローバル一意識別子 (GUID) として取得します。Gets the value of the specified column as a globally unique identifier (GUID). |
GetHashCode() |
既定のハッシュ関数として機能します。Serves as the default hash function. (継承元 Object) |
GetInt16(Int32) |
指定した列の値を 16 ビット符号付き整数として取得します。Gets the value of the specified column as a 16-bit signed integer. |
GetInt32(Int32) |
指定された列の値を 32 ビット符号付き整数として取得します。Gets the value of the specified column as a 32-bit signed integer. |
GetInt64(Int32) |
指定された列の値を 64 ビット符号付き整数として取得します。Gets the value of the specified column as a 64-bit signed integer. |
GetLifetimeService() |
対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。Retrieves the current lifetime service object that controls the lifetime policy for this instance. (継承元 MarshalByRefObject) |
GetName(Int32) |
指定した列の名前を取得します。Gets the name of the specified column. |
GetOrdinal(String) |
列の名前を指定して、列の序数を取得します。Gets the column ordinal, given the name of the column. |
GetSchemaTable() |
DataTable の列メタデータを記述する OleDbDataReader を返します。Returns a DataTable that describes the column metadata of the OleDbDataReader. |
GetString(Int32) |
指定した列の値を文字列として取得します。Gets the value of the specified column as a string. |
GetTimeSpan(Int32) |
指定された列の値を TimeSpan オブジェクトとして取得します。Gets the value of the specified column as a TimeSpan object. |
GetType() |
現在のインスタンスの Type を取得します。Gets the Type of the current instance. (継承元 Object) |
GetValue(Int32) |
指定した序数の列の値をネイティブ形式で取得します。Gets the value of the column at the specified ordinal in its native format. |
GetValues(Object[]) |
オブジェクトの配列に現在行の列値を設定します。Populates an array of objects with the column values of the current row. |
InitializeLifetimeService() |
このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。Obtains a lifetime service object to control the lifetime policy for this instance. (継承元 MarshalByRefObject) |
IsDBNull(Int32) |
存在しない値や欠落値が列に含まれているかどうかを示す値を取得します。Gets a value that indicates whether the column contains nonexistent or missing values. |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object. (継承元 Object) |
MemberwiseClone(Boolean) |
現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。Creates a shallow copy of the current MarshalByRefObject object. (継承元 MarshalByRefObject) |
NextResult() |
バッチ SQL ステートメントの結果を読み取っているときに、次の結果にデータ リーダーを進めます。Advances the data reader to the next result, when reading the results of batch SQL statements. |
Read() |
OleDbDataReader を次のレコードに進めます。Advances the OleDbDataReader to the next record. |
ToString() |
現在のオブジェクトを表す string を返します。Returns a string that represents the current object. (継承元 Object) |
明示的なインターフェイスの実装
IDataRecord.GetData(Int32) |
指定された列序数の IDataReader を返します。Returns an IDataReader for the specified column ordinal. |
IDisposable.Dispose() |
OleDbDataReader クラスの現在のインスタンスによって使用されているリソースを解放します。Releases the resources used by the current instance of the OleDbDataReader class. |
IEnumerable.GetEnumerator() |
コレクションを反復処理する列挙子を返します。Returns an enumerator that iterates through a collection. |