nous Processing=true" in the
            ' connection string, the command is not able
            ' to execute asynchronously.
            Return "Data Source=(local);Integrated Security=true;" & _
              "Initial Catalog=AdventureWorks; Asynchronous Processing=true"
        End Function
    End Module
    

###  Remarks

The [ BeginExecuteReader
](system.data.sqlclient.sqlcommand.beginexecutereader?view=dotnet-plat-
ext-8.0) method starts the process of asynchronously executing a Transact-SQL
statement or stored procedure that returns rows, so that other tasks can run
concurrently while the statement is executing. When the statement has
completed, developers must call the [ EndExecuteReader
](system.data.sqlclient.sqlcommand.endexecutereader?view=dotnet-plat-ext-8.0)
method to finish the operation and retrieve the [ SqlDataReader
](system.data.sqlclient.sqldatareader?view=dotnet-plat-ext-8.0) returned by
the command. The [ BeginExecuteReader
](system.data.sqlclient.sqlcommand.beginexecutereader?view=dotnet-plat-
ext-8.0) method returns immediately, but until the code executes the
corresponding [ EndExecuteReader
](system.data.sqlclient.sqlcommand.endexecutereader?view=dotnet-plat-ext-8.0)
method call, it must not execute any other calls that start a synchronous or
asynchronous execution against the same [ SqlCommand
](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) object. Calling
the [ EndExecuteReader
](system.data.sqlclient.sqlcommand.endexecutereader?view=dotnet-plat-ext-8.0)
before the command's execution is completed causes the [ SqlCommand
](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) object to block
until the execution is finished.

Note that the command text and parameters are sent to the server
synchronously. If a large command or many parameters are sent, this method may
block during writes. After the command is sent, the method returns immediately
without waiting for an answer from the server--that is, reads are
asynchronous. Although command execution is asynchronous, value fetching is
still synchronous. This means that calls to [ Read
](system.data.sqlclient.sqldatareader.read?view=dotnet-plat-ext-8.0) may block
if more data is required and the underlying network's read operation blocks.

Because this overload does not support a callback procedure, developers must
either poll to determine whether the command has completed, using the [
IsCompleted ](system.iasyncresult.iscompleted?view=dotnet-plat-ext-8.0)
property of the [ IAsyncResult ](system.iasyncresult?view=dotnet-plat-ext-8.0)
returned by the [ BeginExecuteReader
](system.data.sqlclient.sqlcommand.beginexecutereader?view=dotnet-plat-
ext-8.0) method; or wait for the completion of one or more commands using the
[ AsyncWaitHandle ](system.iasyncresult.asyncwaithandle?view=dotnet-plat-
ext-8.0) property of the returned [ IAsyncResult
](system.iasyncresult?view=dotnet-plat-ext-8.0) .

If you use [ ExecuteReader
](system.data.sqlclient.sqlcommand.executereader?view=dotnet-plat-ext-8.0) or
[ BeginExecuteReader
](system.data.sqlclient.sqlcommand.beginexecutereader?view=dotnet-plat-
ext-8.0) to access XML data, SQL Server will return any XML results greater
than 2,033 characters in length in multiple rows of 2,033 characters each. To
avoid this behavior, use [ ExecuteXmlReader
](system.data.sqlclient.sqlcommand.executexmlreader?view=dotnet-plat-ext-8.0)
or [ BeginExecuteXmlReader
](system.data.sqlclient.sqlcommand.beginexecutexmlreader?view=dotnet-plat-
ext-8.0) to read FOR XML queries.

This method ignores the [ CommandTimeout
](system.data.sqlclient.sqlcommand.commandtimeout?view=dotnet-plat-ext-8.0)
property.

###  See also

  * [ Connecting and Retrieving Data in ADO.NET ](/en-us/dotnet/framework/data/adonet/retrieving-and-modifying-data)
  * [ Using the .NET Framework Data Provider for SQL Server ](/en-us/dotnet/framework/data/adonet/sql/)
  * [ ADO.NET Overview ](/en-us/dotnet/framework/data/adonet/ado-net-overview)

###  App