Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security
updates, and technical support.

[ Download Microsoft Edge ](https://go.microsoft.com/fwlink/p/?LinkID=2092881
) [ More info about Internet Explorer and Microsoft Edge
](https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-
edge)

Table of contents  Exit focus mode

Language

  *   *   *   * 

Read in English  Save  [ ](https://github.com/dotnet/dotnet-api-
docs/blob/main/xml/System.Data.SqlClient/SqlCommand.xml "Edit This Document")

Table of contents  Read in English  Save  [ Edit
](https://github.com/dotnet/dotnet-api-
docs/blob/main/xml/System.Data.SqlClient/SqlCommand.xml "Edit This Document")
Print

Twitter  LinkedIn  Facebook  Email

Table of contents

#  Sql  Command.  Begin  Execute  Xml  Reader Method

  * Reference 

Feedback

##

##  Definition

Namespace:

     [ System.Data.SqlClient ](system.data.sqlclient?view=dotnet-plat-ext-8.0)

Assembly:

     System.Data.SqlClient.dll 

Assembly:

     System.Data.dll 

Package:

     System.Data.SqlClient v4.8.6 

Important

Some information relates to prerelease product that may be substantially
modified before itâs released. Microsoft makes no warranties, express or
implied, with respect to the information provided here.

Initiates the asynchronous execution of the Transact-SQL statement or stored
procedure that is described by this [ SqlCommand
](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) and returns
results as an [ XmlReader ](system.xml.xmlreader?view=dotnet-plat-ext-8.0)
object.

##  Overloads

[ BeginExecuteXmlReader() ](system.data.sqlclient.sqlcommand.beginexecutexmlreader?view=dotnet-plat-ext-8.0#system-data-sqlclient-sqlcommand-beginexecutexmlreader) |  Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this [ SqlCommand ](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) and returns results as an [ XmlReader ](system.xml.xmlreader?view=dotnet-plat-ext-8.0) object.   
---|---  
[ BeginExecuteXmlReader(AsyncCallback, Object) ](system.data.sqlclient.sqlcommand.beginexecutexmlreader?view=dotnet-plat-ext-8.0#system-data-sqlclient-sqlcommand-beginexecutexmlreader\(system-asynccallback-system-object\)) |  Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this [ SqlCommand ](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) and returns results as an [ XmlReader ](system.xml.xmlreader?view=dotnet-plat-ext-8.0) object, using a callback procedure.   
  
##  BeginExecuteXmlReader()

Initiates the asynchronous execution of the Transact-SQL statement or stored
procedure that is described by this [ SqlCommand
](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) and returns
results as an [ XmlReader ](system.xml.xmlreader?view=dotnet-plat-ext-8.0)
object.

    
    
    public:
     IAsyncResult ^ BeginExecuteXmlReader();
    
    
    public IAsyncResult BeginExecuteXmlReader ();
    
    
    member this.BeginExecuteXmlReader : unit -> IAsyncResult
    
    
    Public Function BeginExecuteXmlReader () As IAsyncResult

####  Returns

[ IAsyncResult ](system.iasyncresult?view=dotnet-plat-ext-8.0)

An [ IAsyncResult ](system.iasyncresult?view=dotnet-plat-ext-8.0) that can be
used to poll or wait for results, or both; this value is also needed when
invoking ` EndExecuteXmlReader ` , which returns a single XML value.

####  Exceptions

[ InvalidCastException ](system.invalidcastexception?view=dotnet-plat-ext-8.0)

A [ SqlDbType ](system.data.sqlclient.sqlparameter.sqldbtype?view=dotnet-plat-
ext-8.0#system-data-sqlclient-sqlparameter-sqldbtype) other than **Binary** or
**VarBinary** was used when [ Value
](system.data.sqlclient.sqlparameter.value?view=dotnet-plat-ext-8.0#system-
data-sqlclient-sqlparameter-value) was set to [ Stream
](system.io.stream?view=dotnet-p