DbDataReader.GetFieldValue<T>(Int32) 方法

定义

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

public:
generic <typename T>
 virtual T GetFieldValue(int ordinal);
public virtual T GetFieldValue<T> (int ordinal);
abstract member GetFieldValue : int -> 'T
override this.GetFieldValue : int -> 'T
Public Overridable Function GetFieldValue(Of T) (ordinal As Integer) As T

类型参数

T

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

参数

ordinal
Int32

从零开始的列序号。The zero-based column ordinal.

返回

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 column index is out of range.

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

适用于