Reputation: 549
I have never used asynchronous calls, could some one please provide me a sample how to call a SQL stored procedure from MVC controller ?
public ActionResult ReProcess(string uname)
{
SqlCommand cmd=new SqlCommand();
cmd.Connection = cnn;
cnn.Open();
cmd.CommandText = "dbo.userdetails_sp";
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.Parameters.Add("@userId", System.Data.SqlDbType.VarChar).Value = uname; ;
cmd.ExecuteNonQuery();
}
Upvotes: 0
Views: 1249
Reputation: 3831
You can use the Task class to encapsulate a method and then run it asyncronously: http://msdn.microsoft.com/en-us/library/system.threading.tasks.task.aspx
var t = Task.Factory.StartNew(() => DoAction());
Upvotes: 1