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

取消标记可用于在命令超时超过前请求放弃操作。The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. 将通过返回的任务对象报告异常。Exceptions will be reported via the returned Task object.

public:
 override System::Threading::Tasks::Task<bool> ^ IsDBNullAsync(int i, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task<bool> IsDBNullAsync (int i, System.Threading.CancellationToken cancellationToken);
override this.IsDBNullAsync : int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Public Overrides Function IsDBNullAsync (i As Integer, cancellationToken As CancellationToken) As Task(Of Boolean)

参数

i
Int32

从零开始的要检索的列。The zero-based column to be retrieved.

cancellationToken
CancellationToken

取消指示,用于对应该取消操作的通知进行传播。The cancellation instruction, which propagates a notification that operations should be canceled. 此构造函数不对取消做保证。This does not guarantee the cancellation. 设置为 CancellationToken.None 将此方法等效于 IsDBNull(Int32)A setting of CancellationToken.None makes this method equivalent to IsDBNull(Int32). 返回任务必须标记为已取消。The returned task must be marked as cancelled.

返回

Task<Boolean>

如果指定的列值与 true 等效,则为 DBNull;否则为 falsetrue if the specified column value is equivalent to DBNull otherwise false.

例外

连接中断或在数据检索期间已关闭。The connection drops or is closed during the data retrieval.

数据检索期间,SqlDataReader 处于关闭状态。The SqlDataReader is closed during the data retrieval.

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

按顺序模式尝试读取上一步骤中读取的列。Trying to read a previously read column in sequential mode.

没有正在进行的异步操作。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.

在连接字符串中指定 Context Connection=trueContext Connection=true is specified in the connection string.

尝试读取不存在的列。Trying to read a column that does not exist.

注解

有关详细信息,请参阅 SqlClient 流支持For more information, see SqlClient Streaming Support.

适用于