DataReaderExtensions.GetFieldValue(DbDataReader, String) DataReaderExtensions.GetFieldValue(DbDataReader, String) DataReaderExtensions.GetFieldValue(DbDataReader, String) DataReaderExtensions.GetFieldValue(DbDataReader, String) Method

定义

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

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T GetFieldValue(System::Data::Common::DbDataReader ^ reader, System::String ^ name);
public static T GetFieldValue<T> (this System.Data.Common.DbDataReader reader, string name);
static member GetFieldValue : System.Data.Common.DbDataReader * string -> 'T
<Extension()>
Public Function GetFieldValue(Of T) (reader As DbDataReader, name As String) As T

类型参数

T

要返回的值的类型。The type of the value to be returned.

参数

reader
DbDataReader DbDataReader DbDataReader DbDataReader

要从中获取列值的数据读取器。The data reader to get the column value from.

name
String String String String

列的名称。The name of the column.

返回

T T T T

指定列的值。The value of the specified column.

异常

在数据检索期间删除或关闭连接。The connection was dropped or closed during data retrieval.

-or- 在数据检索期间关闭数据读取器。The data reader was closed during data retrieval.

- 或 --or-

没有可读取的数据(例如尚未调用第一个 Read(),或调用返回了 false)。There is no data ready to be read (for example, the first Read() hasn't been called, or it returned false).

- 或 --or-

读取器试图按顺序模式读取曾读取的列。The reader tried to read a previously-read column in sequential mode.

-or-

没有正在进行的异步操作。There was an asynchronous operation in progress. 以顺序模式运行时,这适用于所有 Get* 方法,读取流时也可对其进行调用。This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.

指定的名称不是有效的列名。The name specified is not a valid column name.

数据库返回的值不匹配或不能转换为 TThe value returned by the database doesn't match or cannot be cast to T.

适用于