Share via


SqlCommand.ExecuteXmlReaderAsync 方法

定义

重载

ExecuteXmlReaderAsync()

ExecuteXmlReader() 异步版本,它将 发送到 CommandTextConnection 并生成 XmlReader 对象。

将通过返回的任务对象报告异常。

ExecuteXmlReaderAsync(CancellationToken)

ExecuteXmlReader() 异步版本,它将 发送到 CommandTextConnection 并生成 XmlReader 对象。

取消标记可用于在命令超时超过前请求放弃操作。 将通过返回的任务对象报告异常。

ExecuteXmlReaderAsync()

ExecuteXmlReader() 异步版本,它将 发送到 CommandTextConnection 并生成 XmlReader 对象。

将通过返回的任务对象报告异常。

public:
 System::Threading::Tasks::Task<System::Xml::XmlReader ^> ^ ExecuteXmlReaderAsync();
public System.Threading.Tasks.Task<System.Xml.XmlReader> ExecuteXmlReaderAsync ();
member this.ExecuteXmlReaderAsync : unit -> System.Threading.Tasks.Task<System.Xml.XmlReader>
Public Function ExecuteXmlReaderAsync () As Task(Of XmlReader)

返回

表示异步操作的任务。

例外

SqlDbType当 设置为 StreamValue,使用 BinaryVarBinary 以外的 。 有关流式处理的详细信息,请参阅 SqlClient 流支持

- 或 -

SqlDbType设置为 时ValueTextReader ,使用了 CharNCharNVarCharVarCharXml 以外的其他项。

-或-

SqlDbType设置为 时ValueXmlReader ,使用了 Xml 以外的 。

在完成任务前,为同一个实例多次调用 ExecuteScalarAsync(CancellationToken)

- 或 -

流式处理操作期间关闭或删除了 SqlConnection。 有关流式处理的详细信息,请参阅 SqlClient 流支持

执行命令文本时,SQL Server 返回了一个错误。

- 或 -

流式处理操作期间发生了超时。 有关流式处理的详细信息,请参阅 SqlClient 流支持

在流式处理操作期间, XmlReaderTextReader 对象中Stream发生错误。 有关流式处理的详细信息,请参阅 SqlClient 流支持

StreamXmlReader流式处理操作期间, 或 TextReader 对象已关闭。 有关流式处理的详细信息,请参阅 SqlClient 流支持

注解

此方法返回的 XmlReader 不支持异步操作。 有关 SQL Server .NET Framework 数据提供程序中的异步编程的详细信息,请参阅异步编程

注意

对于服务器上长时间运行的查询,请考虑使用 ExecuteXmlReader ,因为通过取消令牌取消查询的已知问题。 此外,请考虑使用 Cancel 方法取消执行。

适用于

ExecuteXmlReaderAsync(CancellationToken)

ExecuteXmlReader() 异步版本,它将 发送到 CommandTextConnection 并生成 XmlReader 对象。

取消标记可用于在命令超时超过前请求放弃操作。 将通过返回的任务对象报告异常。

public:
 System::Threading::Tasks::Task<System::Xml::XmlReader ^> ^ ExecuteXmlReaderAsync(System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Xml.XmlReader> ExecuteXmlReaderAsync (System.Threading.CancellationToken cancellationToken);
member this.ExecuteXmlReaderAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Xml.XmlReader>
Public Function ExecuteXmlReaderAsync (cancellationToken As CancellationToken) As Task(Of XmlReader)

参数

cancellationToken
CancellationToken

取消指示。

返回

表示异步操作的任务。

例外

SqlDbType当 设置为 StreamValue,使用 BinaryVarBinary 以外的 。 有关流式处理的详细信息,请参阅 SqlClient 流支持

- 或 -

SqlDbType设置为 时ValueTextReader ,使用了 CharNCharNVarCharVarCharXml 以外的其他项。

-或-

SqlDbType设置为 时ValueXmlReader ,使用了 Xml 以外的 。

在完成任务前,为同一个实例多次调用 ExecuteScalarAsync(CancellationToken)

- 或 -

流式处理操作期间关闭或删除了 SqlConnection。 有关流式处理的详细信息,请参阅 SqlClient 流支持

执行命令文本时,SQL Server 返回了一个错误。

- 或 -

流式处理操作期间发生了超时。 有关流式处理的详细信息,请参阅 SqlClient 流支持

在流式处理操作期间, XmlReaderTextReader 对象中Stream发生错误。 有关流式处理的详细信息,请参阅 SqlClient 流支持

StreamXmlReader流式处理操作期间, 或 TextReader 对象已关闭。 有关流式处理的详细信息,请参阅 SqlClient 流支持

注解

此方法返回的 XmlReader 不支持异步操作。 有关 SQL Server .NET Framework 数据提供程序中的异步编程的详细信息,请参阅异步编程

适用于