![Use of endexecutenonquery](https://kumkoniak.com/85.jpg)
The BeginExecuteNonQuery method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that does not return rows, so that other tasks can run concurrently while the statement is executing. "Initial Catalog=AdventureWorks Asynchronous Processing=true" Return "Data Source=(local) Integrated Security=SSPI " & _ ' connection string, the command is not able ' If you have not included "Asynchronous Processing=true" in the ' you can retrieve it from a configuration file. ' To avoid storing the connection string in your code, Private Function GetConnectionString() As String IAsyncResult result = command.BeginExecuteNonQuery() Ĭonsole.WriteLine("Waiting (", ex.Message) SqlCommand command = new SqlCommand(commandText, connection) the code displays an indicator as it is working, verifying the the specified command against the connection. Given command text and connection string, asynchronously execute String commandText, string connectionString) Private static void RunCommandAsynchronously( RunCommandAsynchronously(commandText, GetConnectionString()) Ĭonsole.WriteLine("Press ENTER to continue.") "UPDATE Production.Product SET ReorderPoint = ReorderPoint - 1 " + "UPDATE Production.Product SET ReorderPoint = ReorderPoint + 1 " + The WAITFOR statement simply adds enough time to prove the
![use of endexecutenonquery use of endexecutenonquery](https://acocdn.azureedge.net/wp-content/uploads/2022/07/logo-acotel-trasparente-1.png)
This is a simple example that demonstrates the usage of the
![use of endexecutenonquery use of endexecutenonquery](https://csharpcorner-mindcrackerinc.netdna-ssl.com/UploadFile/47548d/async-sqlconnection-in-Asp-Net-4-5/Images/Async%20SqlConnection%20in%20Aspnet.jpg)
Normally, you would not take efforts to make your commands run slower, but doing this in this case makes it easier to demonstrate the asynchronous behavior. In order to emulate a long-running process, this example inserts a WAITFOR statement in the command text. The following console application creates updates data within the AdventureWorks sample database, doing its work asynchronously.
![use of endexecutenonquery use of endexecutenonquery](https://i.stack.imgur.com/5Nk8j.png)
For more information about streaming, see SqlClient Streaming Support. The Stream, XmlReader or TextReader object was closed during a streaming operation.
![Use of endexecutenonquery](https://kumkoniak.com/85.jpg)