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() CloseAsync() CloseAsync() CloseAsync()
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。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 使用的托管资源,还可以选择释放非托管资源。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)

获取指定列的布尔值形式的值。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)

从指定列中指定索引处开始读取指定字节数,并将其写入缓冲区中从指定位置开始的缓冲区。Reads a specified number of bytes from the specified column starting at a specified index and writes them to a buffer starting at a specified position in the buffer.

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)

从指定列中指定索引处开始读取指定字符数,并将其写入从指定位置开始的缓冲区。Reads a specified number of characters from a specified column starting at a specified index, and writes them to a buffer starting at a specified position.

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

返回所请求列的嵌套数据读取器。Returns a nested data reader for the requested column.

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 对象,可以使用提供程序特定的实现对该对象进行重写。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.

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()

返回一个可用于循环访问数据读取器中的行的 IEnumeratorReturns 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)

获取指定列的值作为请求的类型。Gets the value of the specified column as the requested type.

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

异步获取指定列的值作为请求的类型。Asynchronously gets the value of the specified column as the requested 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 the requested 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 位有符号整数的形式获取指定列的值。Gets the value of the specified column as a 64-bit signed integer.

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

检索控制此实例的生存期策略的当前生存期服务对象。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)

获取指定列的特定于提供程序的类型。Gets the provider-specific type of the specified column.

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

以特定于提供程序的类型实例的形式获取指定列的值。Gets the value of the specified column as an instance of a provider-specific type.

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)

获取从指定列检索数据的流。Gets a stream to retrieve data from the specified column.

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)

获取文本读取器以从列中检索数据。Gets a text reader to retrieve data from the column.

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)

异步获取一个值,该值指示列中是否包含不存在的或缺少的值。Asynchronously 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)

异步获取一个值,该值指示列中是否包含不存在的或缺少的值。Asynchronously gets a value that indicates whether the column contains non-existent or missing values.

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

创建当前 Object 的浅表副本。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()

在读取一批语句的结果时,使读取器异步前进到下一个结果。Asynchronously advances the reader to the next result when reading the results of a batch of statements.

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

在读取一批语句的结果时,使读取器异步前进到下一个结果。Asynchronously advances the reader to the next result when reading the results of a batch of statements.

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

使读取器前进到结果集中的下一条记录。Advances the reader to the next record in a result set.

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

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

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

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

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).

扩展方法

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)

获取指定列的布尔值形式的值。Gets the value of the specified column as a Boolean.

GetByte(DbDataReader, String) GetByte(DbDataReader, String) GetByte(DbDataReader, String) GetByte(DbDataReader, String)

以字节的形式获取指定列的值。Gets the value of the specified column as a byte.

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)

从指定列中指定索引处开始读取指定字节数,并将其写入缓冲区中从指定位置开始的缓冲区。Reads a specified number of bytes from the specified column starting at a specified index and writes them to a buffer starting at a specified position in the buffer.

GetChar(DbDataReader, String) GetChar(DbDataReader, String) GetChar(DbDataReader, String) GetChar(DbDataReader, String)

以单个字符的形式获取指定列的值。Gets the value of the specified column as a single character.

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)

从指定列中指定索引处开始读取指定字符数,并将其写入从指定位置开始的缓冲区。Reads a specified number of characters from a specified column starting at a specified index, and writes them to a buffer starting at a specified position.

GetData(DbDataReader, String) GetData(DbDataReader, String) GetData(DbDataReader, String) GetData(DbDataReader, String)

返回所请求列的嵌套数据读取器。Returns a nested data reader for the requested column.

GetDataTypeName(DbDataReader, String) GetDataTypeName(DbDataReader, String) GetDataTypeName(DbDataReader, String) GetDataTypeName(DbDataReader, String)

获取指定列的数据类型的名称。Gets name of the data type of the specified column.

GetDateTime(DbDataReader, String) GetDateTime(DbDataReader, String) GetDateTime(DbDataReader, String) GetDateTime(DbDataReader, String)

DateTime 对象的形式获取指定列的值。Gets the value of the specified column as a DateTime object.

GetDecimal(DbDataReader, String) GetDecimal(DbDataReader, String) GetDecimal(DbDataReader, String) GetDecimal(DbDataReader, String)

获取指定列的 Decimal 形式的值。Gets the value of the specified column as a Decimal.

GetDouble(DbDataReader, String) GetDouble(DbDataReader, String) GetDouble(DbDataReader, String) GetDouble(DbDataReader, String)

以双精度浮点数字的形式获取指定列的值。Gets the value of the specified column as a double-precision floating point number.

GetFieldType(DbDataReader, String) GetFieldType(DbDataReader, String) GetFieldType(DbDataReader, String) GetFieldType(DbDataReader, String)

获取指定列的数据类型。Gets the data type of the specified column.

GetFieldValue<T>(DbDataReader, String) GetFieldValue<T>(DbDataReader, String) GetFieldValue<T>(DbDataReader, String) GetFieldValue<T>(DbDataReader, String)

获取指定列的值作为请求的类型。Gets the value of the specified column as the requested type.

GetFieldValueAsync<T>(DbDataReader, String, CancellationToken) GetFieldValueAsync<T>(DbDataReader, String, CancellationToken) GetFieldValueAsync<T>(DbDataReader, String, CancellationToken) GetFieldValueAsync<T>(DbDataReader, String, CancellationToken)

异步获取指定列的值作为请求的类型。Asynchronously gets the value of the specified column as the requested type.

GetFloat(DbDataReader, String) GetFloat(DbDataReader, String) GetFloat(DbDataReader, String) GetFloat(DbDataReader, String)

以单精度浮点数字的形式获取指定列的值。Gets the value of the specified column as a single-precision floating point number.

GetGuid(DbDataReader, String) GetGuid(DbDataReader, String) GetGuid(DbDataReader, String) GetGuid(DbDataReader, String)

获取指定列的值作为全局唯一标识符 (GUID)。Gets the value of the specified column as a globally unique identifier (GUID).

GetInt16(DbDataReader, String) GetInt16(DbDataReader, String) GetInt16(DbDataReader, String) GetInt16(DbDataReader, String)

获取指定列的 16 位有符号整数形式的值。Gets the value of the specified column as a 16-bit signed integer.

GetInt32(DbDataReader, String) GetInt32(DbDataReader, String) GetInt32(DbDataReader, String) GetInt32(DbDataReader, String)

获取指定列的 32 位带符号整数形式的值。Gets the value of the specified column as a 32-bit signed integer.

GetInt64(DbDataReader, String) GetInt64(DbDataReader, String) GetInt64(DbDataReader, String) GetInt64(DbDataReader, String)

以 64 位有符号整数的形式获取指定列的值。Gets the value of the specified column as a 64-bit signed integer.

GetProviderSpecificFieldType(DbDataReader, String) GetProviderSpecificFieldType(DbDataReader, String) GetProviderSpecificFieldType(DbDataReader, String) GetProviderSpecificFieldType(DbDataReader, String)

获取指定列的特定于提供程序的类型。Gets the provider-specific type of the specified column.

GetProviderSpecificValue(DbDataReader, String) GetProviderSpecificValue(DbDataReader, String) GetProviderSpecificValue(DbDataReader, String) GetProviderSpecificValue(DbDataReader, String)

以特定于提供程序的类型实例的形式获取指定列的值。Gets the value of the specified column as an instance of a provider-specific type.

GetStream(DbDataReader, String) GetStream(DbDataReader, String) GetStream(DbDataReader, String) GetStream(DbDataReader, String)

获取从指定列检索数据的流。Gets a stream to retrieve data from the specified column.

GetString(DbDataReader, String) GetString(DbDataReader, String) GetString(DbDataReader, String) GetString(DbDataReader, String)

String 实例的形式获取指定列的值。Gets the value of the specified column as an instance of String.

GetTextReader(DbDataReader, String) GetTextReader(DbDataReader, String) GetTextReader(DbDataReader, String) GetTextReader(DbDataReader, String)

获取文本读取器以从列中检索数据。Gets a text reader to retrieve data from the column.

GetValue(DbDataReader, String) GetValue(DbDataReader, String) GetValue(DbDataReader, String) GetValue(DbDataReader, String)

Object 实例的形式获取指定列的值。Gets the value of the specified column as an instance of Object.

IsDBNull(DbDataReader, String) IsDBNull(DbDataReader, String) IsDBNull(DbDataReader, String) IsDBNull(DbDataReader, String)

获取一个值,该值指示列中是否包含不存在或丢失的值。Gets a value that indicates whether the column contains nonexistent or missing values.

IsDBNullAsync(DbDataReader, String, CancellationToken) IsDBNullAsync(DbDataReader, String, CancellationToken) IsDBNullAsync(DbDataReader, String, CancellationToken) IsDBNullAsync(DbDataReader, String, CancellationToken)

异步获取一个值,该值指示列中是否包含不存在的或缺少的值。Asynchronously gets a value that indicates whether the column contains non-existent or missing values.

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)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅