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 对象。

例外

asyncResult 参数为 null(在 Microsoft Visual Basic 中为 Nothing

不止一次为单个命令执行调用了 EndExecuteReader(IAsyncResult),或该方法不匹配其执行方法(例如,代码调用了 EndExecuteReader(IAsyncResult) 以完成对 BeginExecuteXmlReader() 调用的执行。

示例

有关演示如何使用 EndExecuteReader 方法的示例,请参阅 BeginExecuteReader

注解

调用 BeginExecuteReader 以执行 Transact-SQL 语句时,必须调用 EndExecuteReader 才能完成操作。 如果执行命令的过程尚未完成,此方法将阻止,直到操作完成。 用户可以使用 方法返回BeginExecuteReader的 实例来验证命令是否已完成其操作IAsyncResult。 如果在对 的调用 BeginExecuteReader中指定了回调过程,则必须调用此方法。

适用于

另请参阅