Stored procedure is not executing after another method call

Santosh Umarani 81 Reputation points
2022-02-15T07:30:56.707+00:00

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

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,651 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Olaf Helper 44,056 Reputation points
    2022-02-15T07:59:27.447+00:00

    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?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.