Mid From PDF SQL SQL & Databases

How do you execute a stored procedure asynchronously? Executing stored procedures asynchronously can improve the performance of applications by allowing other tasks to run while waiting for the procedure to finish. Example (C#): using (SqlConnection conn = new SqlConnection(connectionString)) {

wait conn.OpenAsync();

using (SqlCommand cmd = new SqlCommand("GetEmployeeDetails",

conn))

{
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add(new SqlParameter("@emp_id",

SqlDbType.Int)).Value = 101;
using (SqlDataReader reader = await

cmd.ExecuteReaderAsync())

{

while (await reader.ReadAsync())

{

Console.WriteLine(reader["name"]);

}
}
}
}

More from SQL Server Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details