共用方式為


SqlCommand.EndExecuteReader(IAsyncResult) 方法

定義

完成 Transact-SQL 語句的非同步執行,並傳回要求的 SqlDataReader

public:
 Microsoft::Data::SqlClient::SqlDataReader ^ EndExecuteReader(IAsyncResult ^ asyncResult);
public Microsoft.Data.SqlClient.SqlDataReader EndExecuteReader (IAsyncResult asyncResult);
member this.EndExecuteReader : IAsyncResult -> Microsoft.Data.SqlClient.SqlDataReader
Public Function EndExecuteReader (asyncResult As IAsyncResult) As SqlDataReader

參數

asyncResult
IAsyncResult

IAsyncResult呼叫 所傳回的 BeginExecuteReader()

傳回

SqlDataReader 物件,可用於擷取要求的資料列。

例外狀況

asyncResult 參數為 Microsoft Visual Basic) 中的 null Nothing (

EndExecuteReader(IAsyncResult) 針對單一命令執行呼叫多次,或方法與其執行方法不相符 (例如,呼叫 EndExecuteReader(IAsyncResult) 以完成呼叫 BeginExecuteXmlReader() 的程式碼。

範例

如需示範如何使用 方法的 EndExecuteReader 範例,請參閱 BeginExecuteReader

備註

當您呼叫 BeginExecuteReader 以執行 Transact-SQL 語句時,您必須呼叫 EndExecuteReader 才能完成作業。 如果執行命令的程式尚未完成,這個方法會封鎖直到作業完成為止。 使用者可以使用 方法所傳回的 BeginExecuteReader 實例,確認命令已完成其作業 IAsyncResult 。 如果在呼叫 BeginExecuteReader 中指定回呼程式,則必須呼叫這個方法。

適用於