SqlCommand.EndExecuteReader(IAsyncResult) 方法

定義

完成 Transact-SQL 陳述式的非同步執行,傳回要求的 SqlDataReader

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

參數

asyncResult
IAsyncResult

呼叫 IAsyncResult 所傳回的 BeginExecuteReader()

傳回

SqlDataReader

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

例外狀況

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

呼叫多次 EndExecuteReader(IAsyncResult) 來執行單一命令,或方法不符合其執行方法 (例如程式碼呼叫了 EndExecuteReader(IAsyncResult) 來完成執行 BeginExecuteXmlReader() 呼叫)。

範例

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

備註

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

適用於

另請參閱