I have a CLR stored procedure that i want to execute asynchronously from C#.
the code is as follow:
private delegate void GeneratePayrollDelegate(string payProcessID);
public void GeneratePayroll(string payProcessID)
{
GeneratePayrollDelegate del = new GeneratePayrollDelegate(GeneratePayrollAsync);
del.BeginInvoke(payProcessID, null, null);
}
public void GeneratePayrollAsync(string payProcessID)
{
try
{
using (SqlConnection connection = new SqlConnection(DLConnectionStringHelper.GetConnectionString() + "; async=true;"))
{
using (SqlCommand cmd = new SqlCommand("proc_GeneratePayroll", connection))
{
cmd.CommandTimeout = 3600;
cmd.CommandType = CommandType.StoredProcedure;
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
}
}
}
catch (Exception ex) { _Exceptions.ManageExceptions(ex); }
}
This stored procedure executes successfully if it runs from sql.
When it executes from this code above, it gives no row inside the CLR stored procedure when trying to retrieve the row by the ID sent as parameter.
Need help!