SqlDataReader.NextResultAsync(CancellationToken) 方法

定義

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

取消語彙基元可用於要求在命令逾時之前捨棄作業。The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. 例外狀況將經由傳回的 Task 物件回報。Exceptions will be reported via the returned Task object.

public:
 override System::Threading::Tasks::Task<bool> ^ NextResultAsync(System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task<bool> NextResultAsync (System.Threading.CancellationToken cancellationToken);
override this.NextResultAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>

參數

cancellationToken
CancellationToken

取消指令。The cancellation instruction.

傳回

表示非同步作業的工作。A task representing the asynchronous operation.

例外狀況

在工作完成前,對同一個執行個體呼叫 NextResultAsync(CancellationToken) 不止一次。Calling NextResultAsync(CancellationToken) more than once for the same instance before task completion.

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

SQL Server 於執行命令文字時傳回錯誤。SQL Server returned an error while executing the command text.

備註

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

適用於

另請參閱