Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.SqlClient;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string connectionString = "Server=VAKHO-PC; Database=TestDB; Integrated Security=true; Asynchronous Processing=true;";
- SqlConnection con = new SqlConnection(connectionString);
- string sqlCommand = "UPDATE dbo.Users SET salary=salary+10; " + "WAITFOR DELAY '0:0:10'" + " UPDATE dbo.Users SET salary=salary+10";
- SqlCommand updateCommand = new SqlCommand(sqlCommand, con);
- con.Open();
- Console.WriteLine("Connection Status: " + con.State.ToString());
- IAsyncResult result = updateCommand.BeginExecuteNonQuery();
- while (!result.IsCompleted)
- {
- Console.WriteLine(DateTime.Now.ToLongTimeString());
- System.Threading.Thread.Sleep(2000);
- }
- updateCommand.EndExecuteNonQuery(result);
- con.Close();
- Console.WriteLine("The End");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment