C# program return "Execution Timeout Expired. The timeout period slapsed prior to completion of the operation or the server is not responding."

MSDN4 kml 6 Reputation points
2022-11-28T09:25:19.42+00:00

C# Program throw "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.".
The inner exception message is "The wait operation timed out.".

using (var connection = new SqlConnection(ConnectionString))  
{  
    DataSet ds = new DataSet();  
    try  
    {  
        SqlCommand cmd = new SqlCommand("stored_procedure_name", connection);  
        cmd.Parameters.Add("@param1", SqlDbType.VarChar).Value = in_value;  
        cmd.CommandType = CommandType.StoredProcedure;  

        using (SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd))  
        {  
            dataAdapter.Fill(ds);  
        }  
    }  
    catch (Exception ex)  
    {  
        Log.Write(ex.Message);  
        if (ex.InnerException != null)  
            Log.Write(ex.InnerException.Message);  
    }  
}  

The stored procedure selects the records and then updates the status of the records.
Normally, the number of records is about 200 rows.

The SQL Server and the program are running on separate machines.

The program is running for a few years. The above timeout message throws randomly. It is not related to the number of selected records.
According to the log, from calling to exception throw is within 2 mins.

From the SQL Server log, no deadlock. system_idel and memory_utilization are normal.
From the system event log, no error or warning within the error throw period.

No idea of the timeout reason.

Community Center | Not monitored
{count} vote

1 answer

Sort by: Most helpful
  1. Tom Phillips 17,771 Reputation points
    2022-11-28T15:30:54.367+00:00
    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.