DbDataReader DbDataReader DbDataReader DbDataReader Class

定義

從資料來源讀取順向的資料流。Reads a forward-only stream of rows from a data source.

public ref class DbDataReader abstract : MarshalByRefObject, IDisposable, System::Collections::IEnumerable, System::Data::IDataReader
public abstract class DbDataReader : MarshalByRefObject, IDisposable, System.Collections.IEnumerable, System.Data.IDataReader
type DbDataReader = class
    inherit MarshalByRefObject
    interface IDataReader
    interface IEnumerable
    interface IDisposable
    interface IDataRecord
Public MustInherit Class DbDataReader
Inherits MarshalByRefObject
Implements IDataReader, IDisposable, IEnumerable
繼承
衍生
實作

建構函式

DbDataReader() DbDataReader() DbDataReader() DbDataReader()

初始化 DbDataReader 類別的新執行個體。Initializes a new instance of the DbDataReader class.

屬性

Depth Depth Depth Depth

取得值,表示目前資料列的巢狀深度。Gets a value indicating the depth of nesting for the current row.

FieldCount FieldCount FieldCount FieldCount

取得目前資料列中的資料行數目。Gets the number of columns in the current row.

HasRows HasRows HasRows HasRows

取得表示這個 DbDataReader 是否包含一或多個資料列的值。Gets a value that indicates whether this DbDataReader contains one or more rows.

IsClosed IsClosed IsClosed IsClosed

取得值,表示 DbDataReader 是否關閉。Gets a value indicating whether the DbDataReader is closed.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

取得指定之資料行的值做為 Object 的執行個體。Gets the value of the specified column as an instance of Object.

Item[String] Item[String] Item[String] Item[String]

取得指定之資料行的值做為 Object 的執行個體。Gets the value of the specified column as an instance of Object.

RecordsAffected RecordsAffected RecordsAffected RecordsAffected

取得因執行 SQL 陳述式所變更、插入或刪除的資料列數目。Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.

VisibleFieldCount VisibleFieldCount VisibleFieldCount VisibleFieldCount

取得 DbDataReader 中沒有隱藏的欄位數。Gets the number of fields in the DbDataReader that are not hidden.

方法

Close() Close() Close() Close()

關閉 DbDataReader 物件。Closes the DbDataReader object.

CloseAsync(CancellationToken) CloseAsync(CancellationToken) CloseAsync(CancellationToken) CloseAsync(CancellationToken)
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

釋放 DbDataReader 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the DbDataReader class.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 DbDataReader 使用的 Managed 資源,並選擇性釋放 Unmanaged 資源。Releases the managed resources used by the DbDataReader and optionally releases the unmanaged resources.

DisposeAsync() DisposeAsync() DisposeAsync() DisposeAsync()
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBoolean(Int32) GetBoolean(Int32) GetBoolean(Int32) GetBoolean(Int32)

取得指定之資料行的值做為布林值 (Boolean)。Gets the value of the specified column as a Boolean.

GetByte(Int32) GetByte(Int32) GetByte(Int32) GetByte(Int32)

取得指定資料行的值做為位元組。Gets the value of the specified column as a byte.

GetBytes(Int32, Int64, Byte[], Int32, Int32) GetBytes(Int32, Int64, Byte[], Int32, Int32) GetBytes(Int32, Int64, Byte[], Int32, Int32) GetBytes(Int32, Int64, Byte[], Int32, Int32)

從指定的資料行 (開始於 dataOffset 指定的位置) 將位元組的資料流讀入緩衝區 (開始於 bufferOffset 指定的位置)。Reads a stream of bytes from the specified column, starting at location indicated by dataOffset, into the buffer, starting at the location indicated by bufferOffset.

GetChar(Int32) GetChar(Int32) GetChar(Int32) GetChar(Int32)

取得指定的資料行值做為單一字元。Gets the value of the specified column as a single character.

GetChars(Int32, Int64, Char[], Int32, Int32) GetChars(Int32, Int64, Char[], Int32, Int32) GetChars(Int32, Int64, Char[], Int32, Int32) GetChars(Int32, Int64, Char[], Int32, Int32)

從指定的資料行 (開始於 dataOffset 指定的位置) 將字元的資料流讀入緩衝區 (開始於 bufferOffset 指定的位置)。Reads a stream of characters from the specified column, starting at location indicated by dataOffset, into the buffer, starting at the location indicated by bufferOffset.

GetData(Int32) GetData(Int32) GetData(Int32) GetData(Int32)

傳回要求之資料行序數的 DbDataReader 物件。Returns a DbDataReader object for the requested column ordinal.

GetDataTypeName(Int32) GetDataTypeName(Int32) GetDataTypeName(Int32) GetDataTypeName(Int32)

取得指定資料行的資料類型名稱。Gets name of the data type of the specified column.

GetDateTime(Int32) GetDateTime(Int32) GetDateTime(Int32) GetDateTime(Int32)

取得指定之資料行的值做為 DateTime 物件。Gets the value of the specified column as a DateTime object.

GetDbDataReader(Int32) GetDbDataReader(Int32) GetDbDataReader(Int32) GetDbDataReader(Int32)

傳回所要求資料行序數的 DbDataReader 物件,可使用提供者特定的實作 (Implementation) 覆寫。Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation.

GetDecimal(Int32) GetDecimal(Int32) GetDecimal(Int32) GetDecimal(Int32)

取得指定之資料行的值做為 Decimal 物件。Gets the value of the specified column as a Decimal object.

GetDouble(Int32) GetDouble(Int32) GetDouble(Int32) GetDouble(Int32)

取得指定資料行的值做為雙精確度浮點數。Gets the value of the specified column as a double-precision floating point number.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回 IEnumerator,可用來逐一查看資料讀取器中的資料列。Returns an IEnumerator that can be used to iterate through the rows in the data reader.

GetFieldType(Int32) GetFieldType(Int32) GetFieldType(Int32) GetFieldType(Int32)

取得指定資料行的資料類型。Gets the data type of the specified column.

GetFieldValue<T>(Int32) GetFieldValue<T>(Int32) GetFieldValue<T>(Int32) GetFieldValue<T>(Int32)

同步取得指定之資料行的值做為型別。Synchronously gets the value of the specified column as a type.

GetFieldValueAsync<T>(Int32) GetFieldValueAsync<T>(Int32) GetFieldValueAsync<T>(Int32) GetFieldValueAsync<T>(Int32)

非同步取得指定之資料行的值做為型別。Asynchronously gets the value of the specified column as a type.

GetFieldValueAsync<T>(Int32, CancellationToken) GetFieldValueAsync<T>(Int32, CancellationToken) GetFieldValueAsync<T>(Int32, CancellationToken) GetFieldValueAsync<T>(Int32, CancellationToken)

非同步取得指定之資料行的值做為型別。Asynchronously gets the value of the specified column as a type.

GetFloat(Int32) GetFloat(Int32) GetFloat(Int32) GetFloat(Int32)

取得指定資料行的值做為單精確度浮點數。Gets the value of the specified column as a single-precision floating point number.

GetGuid(Int32) GetGuid(Int32) GetGuid(Int32) GetGuid(Int32)

取得指定資料行的值做為全域唯一識別項 (GUID)。Gets the value of the specified column as a globally-unique identifier (GUID).

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetInt16(Int32) GetInt16(Int32) GetInt16(Int32) GetInt16(Int32)

取得指定資料行的值做為 16 位元帶正負號的整數。Gets the value of the specified column as a 16-bit signed integer.

GetInt32(Int32) GetInt32(Int32) GetInt32(Int32) GetInt32(Int32)

取得指定資料行的值作為 32 位元帶正負號的整數。Gets the value of the specified column as a 32-bit signed integer.

GetInt64(Int32) GetInt64(Int32) GetInt64(Int32) GetInt64(Int32)

取得指定資料行的值做為 64 位元帶正負號的整數 (Signed Integer)。Gets the value of the specified column as a 64-bit signed integer.

GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetName(Int32) GetName(Int32) GetName(Int32) GetName(Int32)

在已知以零為基底的資料行序數的情況下,取得資料行的名稱。Gets the name of the column, given the zero-based column ordinal.

GetOrdinal(String) GetOrdinal(String) GetOrdinal(String) GetOrdinal(String)

在已知資料行名稱的情況下,取得資料行序數。Gets the column ordinal given the name of the column.

GetProviderSpecificFieldType(Int32) GetProviderSpecificFieldType(Int32) GetProviderSpecificFieldType(Int32) GetProviderSpecificFieldType(Int32)

傳回指定資料行的提供者特定的欄位型別 (Field Type)。Returns the provider-specific field type of the specified column.

GetProviderSpecificValue(Int32) GetProviderSpecificValue(Int32) GetProviderSpecificValue(Int32) GetProviderSpecificValue(Int32)

取得指定之資料行的值做為 Object 的執行個體。Gets the value of the specified column as an instance of Object.

GetProviderSpecificValues(Object[]) GetProviderSpecificValues(Object[]) GetProviderSpecificValues(Object[]) GetProviderSpecificValues(Object[])

為目前的資料列在集合中取得所有提供者特定的屬性資料行。Gets all provider-specific attribute columns in the collection for the current row.

GetSchemaTable() GetSchemaTable() GetSchemaTable() GetSchemaTable()

傳回 DataTable,以描述 DbDataReader 的資料行中繼資料。Returns a DataTable that describes the column metadata of the DbDataReader.

GetStream(Int32) GetStream(Int32) GetStream(Int32) GetStream(Int32)

擷取資料做為StreamRetrieves data as a Stream.

GetString(Int32) GetString(Int32) GetString(Int32) GetString(Int32)

取得指定之資料行的值做為 String 的執行個體。Gets the value of the specified column as an instance of String.

GetTextReader(Int32) GetTextReader(Int32) GetTextReader(Int32) GetTextReader(Int32)

擷取資料做為TextReaderRetrieves data as a TextReader.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
GetValue(Int32) GetValue(Int32) GetValue(Int32) GetValue(Int32)

取得指定之資料行的值做為 Object 的執行個體。Gets the value of the specified column as an instance of Object.

GetValues(Object[]) GetValues(Object[]) GetValues(Object[]) GetValues(Object[])

使用目前資料列的資料行值填入物件陣列。Populates an array of objects with the column values of the current row.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
IsDBNull(Int32) IsDBNull(Int32) IsDBNull(Int32) IsDBNull(Int32)

取得值,這個值表示資料行是否包含不存在或遺漏的值。Gets a value that indicates whether the column contains nonexistent or missing values.

IsDBNullAsync(Int32) IsDBNullAsync(Int32) IsDBNullAsync(Int32) IsDBNullAsync(Int32)

IsDBNull(Int32) 的非同步版本,該版本會取得值,表示資料行是否包含不存在或遺漏的值。An asynchronous version of IsDBNull(Int32), which gets a value that indicates whether the column contains non-existent or missing values.

IsDBNullAsync(Int32, CancellationToken) IsDBNullAsync(Int32, CancellationToken) IsDBNullAsync(Int32, CancellationToken) IsDBNullAsync(Int32, CancellationToken)

IsDBNull(Int32) 的非同步版本,該版本會取得值,表示資料行是否包含不存在或遺漏的值。An asynchronous version of IsDBNull(Int32), which gets a value that indicates whether the column contains non-existent or missing values. 選擇性地傳送通知,表示應取消作業。Optionally, sends a notification that operations should be cancelled.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
NextResult() NextResult() NextResult() NextResult()

在讀取陳述式批次的結果時,會將讀取器向前移到下一個結果。Advances the reader to the next result when reading the results of a batch of statements.

NextResultAsync() NextResultAsync() NextResultAsync() NextResultAsync()

NextResult() 的非同步版本,該版本會在讀取批次陳述式的結果時,將讀取器前移至下一個結果。An asynchronous version of NextResult(), which advances the reader to the next result when reading the results of a batch of statements.

以 CancellationToken.None 叫用 NextResultAsync(CancellationToken)Invokes NextResultAsync(CancellationToken) with CancellationToken.None.

NextResultAsync(CancellationToken) NextResultAsync(CancellationToken) NextResultAsync(CancellationToken) NextResultAsync(CancellationToken)

這是 NextResult() 的非同步版本。This is the asynchronous version of NextResult(). 提供者應該覆寫為適當的實作。Providers should override with an appropriate implementation. 可以選擇性忽略 cancellationTokenThe cancellationToken may optionally be ignored.

預設實作會叫用同步NextResult()方法,並傳回完成的工作,封鎖呼叫的執行緒。The default implementation invokes the synchronous NextResult() method and returns a completed task, blocking the calling thread. 如果傳遞一個已經被取消的 cancellationToken,預設實作會傳回已取消的工作。The default implementation will return a cancelled task if passed an already cancelled cancellationToken. NextResult() 擲回的例外狀況會透過傳回的工作例外狀況屬性來傳送。Exceptions thrown by NextResult() will be communicated via the returned Task Exception property.

傳回的工作尚未完成時,不應該叫用 DbDataReader 物件的其他方法和屬性。Other methods and properties of the DbDataReader object should not be invoked while the returned Task is not yet completed.

Read() Read() Read() Read()

將讀取器向前移到結果集中的下一個資料錄。Advances the reader to the next record in a result set.

ReadAsync() ReadAsync() ReadAsync() ReadAsync()

非同步版本的 Read(),這個版本會將讀取器前移至結果集中的下一筆記錄。An asynchronous version of Read(), which advances the reader to the next record in a result set. 這個方法會叫用 ReadAsync(CancellationToken) 與 CancellationToken.None。This method invokes ReadAsync(CancellationToken) with CancellationToken.None.

ReadAsync(CancellationToken) ReadAsync(CancellationToken) ReadAsync(CancellationToken) ReadAsync(CancellationToken)

這是 Read() 的非同步版本。This is the asynchronous version of Read(). 提供者應該覆寫為適當的實作。Providers should override with an appropriate implementation. 可以選擇性地忽略 cancellationToken。The cancellationToken may optionally be ignored.

預設實作會叫用同步Read()方法,並傳回完成的工作,封鎖呼叫的執行緒。The default implementation invokes the synchronous Read() method and returns a completed task, blocking the calling thread. 如果傳遞一個已經被取消的 cancellationToken,預設實作會傳回已取消的工作。The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Read 擲回的例外狀況會透過傳回的工作例外狀況屬性來傳送。Exceptions thrown by Read will be communicated via the returned Task Exception property.

在傳回的工作完成之前,不叫用 DbDataReader 物件的其他方法及屬性。Do not invoke other methods and properties of the DbDataReader object until the returned Task is complete.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

IDataReader.Close() IDataReader.Close() IDataReader.Close() IDataReader.Close()
IDataReader.GetSchemaTable() IDataReader.GetSchemaTable() IDataReader.GetSchemaTable() IDataReader.GetSchemaTable()
IDataRecord.GetData(Int32) IDataRecord.GetData(Int32) IDataRecord.GetData(Int32) IDataRecord.GetData(Int32)

如需這個成員的說明,請參閱 GetData(Int32)For a description of this member, see GetData(Int32).

Extension Methods

CanGetColumnSchema(DbDataReader) CanGetColumnSchema(DbDataReader) CanGetColumnSchema(DbDataReader) CanGetColumnSchema(DbDataReader)

取得值,指出 DbDataReader 是否可取得資料行結構描述。Gets a value that indicates whether a DbDataReader can get a column schema.

GetColumnSchema(DbDataReader) GetColumnSchema(DbDataReader) GetColumnSchema(DbDataReader) GetColumnSchema(DbDataReader)

取得 DbDataReader 的資料行結構描述 (DbColumn 集合)。Gets the column schema (DbColumn collection) for a DbDataReader.

GetBoolean(DbDataReader, String) GetBoolean(DbDataReader, String) GetBoolean(DbDataReader, String) GetBoolean(DbDataReader, String)
GetByte(DbDataReader, String) GetByte(DbDataReader, String) GetByte(DbDataReader, String) GetByte(DbDataReader, String)
GetBytes(DbDataReader, String, Int64, Byte[], Int32, Int32) GetBytes(DbDataReader, String, Int64, Byte[], Int32, Int32) GetBytes(DbDataReader, String, Int64, Byte[], Int32, Int32) GetBytes(DbDataReader, String, Int64, Byte[], Int32, Int32)
GetChar(DbDataReader, String) GetChar(DbDataReader, String) GetChar(DbDataReader, String) GetChar(DbDataReader, String)
GetChars(DbDataReader, String, Int64, Char[], Int32, Int32) GetChars(DbDataReader, String, Int64, Char[], Int32, Int32) GetChars(DbDataReader, String, Int64, Char[], Int32, Int32) GetChars(DbDataReader, String, Int64, Char[], Int32, Int32)
GetData(DbDataReader, String) GetData(DbDataReader, String) GetData(DbDataReader, String) GetData(DbDataReader, String)
GetDataTypeName(DbDataReader, String) GetDataTypeName(DbDataReader, String) GetDataTypeName(DbDataReader, String) GetDataTypeName(DbDataReader, String)
GetDateTime(DbDataReader, String) GetDateTime(DbDataReader, String) GetDateTime(DbDataReader, String) GetDateTime(DbDataReader, String)
GetDecimal(DbDataReader, String) GetDecimal(DbDataReader, String) GetDecimal(DbDataReader, String) GetDecimal(DbDataReader, String)
GetDouble(DbDataReader, String) GetDouble(DbDataReader, String) GetDouble(DbDataReader, String) GetDouble(DbDataReader, String)
GetFieldType(DbDataReader, String) GetFieldType(DbDataReader, String) GetFieldType(DbDataReader, String) GetFieldType(DbDataReader, String)
GetFieldValue<T>(DbDataReader, String) GetFieldValue<T>(DbDataReader, String) GetFieldValue<T>(DbDataReader, String) GetFieldValue<T>(DbDataReader, String)
GetFieldValueAsync<T>(DbDataReader, String, CancellationToken) GetFieldValueAsync<T>(DbDataReader, String, CancellationToken) GetFieldValueAsync<T>(DbDataReader, String, CancellationToken) GetFieldValueAsync<T>(DbDataReader, String, CancellationToken)
GetFloat(DbDataReader, String) GetFloat(DbDataReader, String) GetFloat(DbDataReader, String) GetFloat(DbDataReader, String)
GetGuid(DbDataReader, String) GetGuid(DbDataReader, String) GetGuid(DbDataReader, String) GetGuid(DbDataReader, String)
GetInt16(DbDataReader, String) GetInt16(DbDataReader, String) GetInt16(DbDataReader, String) GetInt16(DbDataReader, String)
GetInt32(DbDataReader, String) GetInt32(DbDataReader, String) GetInt32(DbDataReader, String) GetInt32(DbDataReader, String)
GetInt64(DbDataReader, String) GetInt64(DbDataReader, String) GetInt64(DbDataReader, String) GetInt64(DbDataReader, String)
GetProviderSpecificFieldType(DbDataReader, String) GetProviderSpecificFieldType(DbDataReader, String) GetProviderSpecificFieldType(DbDataReader, String) GetProviderSpecificFieldType(DbDataReader, String)
GetProviderSpecificValue(DbDataReader, String) GetProviderSpecificValue(DbDataReader, String) GetProviderSpecificValue(DbDataReader, String) GetProviderSpecificValue(DbDataReader, String)
GetStream(DbDataReader, String) GetStream(DbDataReader, String) GetStream(DbDataReader, String) GetStream(DbDataReader, String)
GetString(DbDataReader, String) GetString(DbDataReader, String) GetString(DbDataReader, String) GetString(DbDataReader, String)
GetTextReader(DbDataReader, String) GetTextReader(DbDataReader, String) GetTextReader(DbDataReader, String) GetTextReader(DbDataReader, String)
GetValue(DbDataReader, String) GetValue(DbDataReader, String) GetValue(DbDataReader, String) GetValue(DbDataReader, String)
IsDBNull(DbDataReader, String) IsDBNull(DbDataReader, String) IsDBNull(DbDataReader, String) IsDBNull(DbDataReader, String)
IsDBNullAsync(DbDataReader, String, CancellationToken) IsDBNullAsync(DbDataReader, String, CancellationToken) IsDBNullAsync(DbDataReader, String, CancellationToken) IsDBNullAsync(DbDataReader, String, CancellationToken)
Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱