You question is a bit vague and so we could only guess.
Why do you think the second SP isn't executed, do you have a logging to validate or why?
Stored procedure is not executing after another method call
Hi,
I have a method called UpdateResultAvailability which basically updates the table "TestResultAvailability" in DB.
private static void UpdateResultAvailability ()
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
// command to update TestResultAvailability
command.ExecuteNonQuery();
connection.Close();
}
}
After this method is called, I am calling another method "RunStoredProcedure" which basically runs stored procedure "sp_UpdateReports"
private static void RunStoredProcedure()
{
using (SqlConnection sqlConnection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand
{
CommandTimeout = 30 * 60,
CommandText = "sp_UpdateReports",
CommandType = CommandType.StoredProcedure,
Connection = sqlConnection
};
sqlConnection.Open();
var x = cmd.ExecuteReader();
sqlConnection.Close();
}
If I run only the method "RunStoredProcedure" or SP in DB, it is executing properly.
However, when I run in sequence like after method "UpdateResultAvailability ", the SP is not executing.
I am not getting what mistake I am doing. Can anyone please let me know what am I doing wrongly or what should I do?
Kindly waiting for your response.
Thanks,
Santosh
1 answer
Sort by: Most helpful
-
Olaf Helper 44,056 Reputation points
2022-02-15T07:59:27.447+00:00