Search code examples
sql-serverdatabasetimeoutsqlconnectionconnection-timeout

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding


hi I'm getting an error Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I'm alredy changed the connect timeout = 60000 and in database my procedure is executes in 43sec. so plz give me some perfect solution

thank you


Solution

  • You should note that Timeout property for SqlConnection object and Timeout property for SqlCommand object are different properties.
    By default command timeout is set to 30 seconds. Set it to 60, and your issue will be solved:

    commandObject.Timeout = 60;
    

    But most likely that you should change your SQL procedure or split it to some parts