使用英语阅读

通过


SqlCommand.EndExecuteReader(IAsyncResult) 方法

定义

完成 Transact-SQL 语句的异步执行,从而返回请求的 SqlDataReader

public System.Data.SqlClient.SqlDataReader EndExecuteReader(IAsyncResult asyncResult);

参数

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中指定了回调过程,则必须调用此方法。

适用于

产品 版本
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

另请参阅