語言

SqlCommand.ExecuteXmlReaderAsync 方法

定義

啟動非同步執行由此 SqlCommand 描述的 Transact-SQL 語句或儲存程序,並將結果以 XmlReader 物件形式回傳。

新開發的話,請使用 Microsoft。Data.SqlClient。 本頁說明了 System.Data.SqlClient。

多載

名稱 Description
ExecuteXmlReaderAsync()

一個非同步版本的 ExecuteXmlReader(),將 傳送 CommandText 到 並 Connection 建立一個 XmlReader 物件。

例外將透過回傳的任務物件回報。

新開發的話,請使用 Microsoft。Data.SqlClient。 本頁說明了 System.Data.SqlClient。

ExecuteXmlReaderAsync(CancellationToken)

一個非同步版本的 ExecuteXmlReader(),將 傳送 CommandText 到 並 Connection 建立一個 XmlReader 物件。

      The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.

      <p>For new development, use <a href="/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace">Microsoft.Data.SqlClient</a>. This page documents System.Data.SqlClient.</p>

ExecuteXmlReaderAsync()

來源:
System.Data.SqlClient.notsupported.cs

一個非同步版本的 ExecuteXmlReader(),將 傳送 CommandText 到 並 Connection 建立一個 XmlReader 物件。

例外將透過回傳的任務物件回報。

新開發的話,請使用 Microsoft。Data.SqlClient。 本頁說明了 System.Data.SqlClient。

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時,會使用除 Binary 或 VarBinary 以外的 。ValueStream 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

-或-

SqlDbType除了 Char、NChar、NVarChar、VarChar 或 Xml,當 設定為 時,會使用其他 Char、Value、NVarChar、TextReader 或 Xml。

-或-

當 設定為 SqlDbType時,會使用 Xml 以外的 。ValueXmlReader

在同一 ExecuteScalarAsync(CancellationToken) 個實例呼叫超過一次,任務才完成。

-或-

在 SqlConnection 串流操作中關閉或掉落。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

-或-

Context Connection=true 在連接字串中指定。

SQL Server 執行命令文字時回傳錯誤。

-或-

串流操作中發生了一次超時。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

在串流操作中,物件或 發生StreamXmlReaderTextReader錯誤。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

Stream該 , XmlReader 或TextReader物件在串流操作中被關閉。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

備註

此方法回傳的 XmlReader 不支援非同步操作。

欲了解更多關於.NET框架Data Provider for SQL Server 非同步程式設計的資訊,請參見 非同步程式設計。

此方法在任務中儲存所有非使用例外,該方法的同步對應程式可拋出這些例外。 如果回傳的任務中儲存了例外,該例外會在等待任務時拋出。 使用例外錯誤,例如 ArgumentException,仍會同步拋出。 關於儲存的例外,請參見由 ExecuteXmlReader()拋出的例外。

另請參閱

適用於

ExecuteXmlReaderAsync(CancellationToken)

來源:
System.Data.SqlClient.notsupported.cs

一個非同步版本的 ExecuteXmlReader(),將 傳送 CommandText 到 並 Connection 建立一個 XmlReader 物件。

      The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.

      <p>For new development, use <a href="/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace">Microsoft.Data.SqlClient</a>. This page documents System.Data.SqlClient.</p>
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時,會使用除 Binary 或 VarBinary 以外的 。ValueStream 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

-或-

SqlDbType除了 Char、NChar、NVarChar、VarChar 或 Xml,當 設定為 時,會使用其他 Char、Value、NVarChar、TextReader 或 Xml。

-或-

當 設定為 SqlDbType時,會使用 Xml 以外的 。ValueXmlReader

在同一 ExecuteScalarAsync(CancellationToken) 個實例呼叫超過一次,任務才完成。

-或-

在 SqlConnection 串流操作中關閉或掉落。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

-或-

Context Connection=true 在連接字串中指定。

SQL Server 執行命令文字時回傳錯誤。

-或-

串流操作中發生了一次超時。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

在串流操作中,物件或 發生StreamXmlReaderTextReader錯誤。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

Stream該 , XmlReader 或TextReader物件在串流操作中被關閉。 欲了解更多串流資訊,請參閱 SqlClient 串流支援。

取消令牌也被取消了。 此例外會儲存在回傳的任務中。

備註

此方法回傳的 XmlReader 不支援非同步操作。

欲了解更多關於.NET框架Data Provider for SQL Server 非同步程式設計的資訊,請參見 非同步程式設計。

此方法在任務中儲存所有非使用例外,該方法的同步對應程式可拋出這些例外。 如果回傳的任務中儲存了例外,該例外會在等待任務時拋出。 使用例外錯誤,例如 ArgumentException,仍會同步拋出。 關於儲存的例外,請參見由 ExecuteXmlReader()拋出的例外。

另請參閱

適用於