Execution Timeout Expired Error while executing an SQL query

  • Following error comes while executing an SQL query.

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

    This happens after 30 seconds, even though I have set the Command Timeout property to 300 seconds.

    Here’s what I’ve already verified:

    The connection is working fine. I've checked the remote query timeout, and it's set to 0 (unlimited). There are no packet drops or network issues. The query is optimized, properly indexed, and runs in seconds directly on SQL Server. There are no deadlocks, blocking processes, or transactions affecting the command. Connection pooling is not in use, and SQL logs show no issues.

    Any suggestions or insights on what could be causing this issue would be greatly appreciated!

  • You say it runs in seconds when run 'directly'. So presumably you are running it 'indirectly' – can you elaborate on that?


  • I’m running the SQL query through VB.NET code. To check if the query execution time was slow, I executed the query directly on SQL Server and verified that it runs in seconds. The issue with the timeout occurs when I run it through the VB.NET code, even though the query itself executes quickly on SQL Server.

  • OK, understood. Is this a fundamental connection problem (ie, all queries time out), or is there just one particular query which is giving the issue?


  • Which Isolation Level are you using to execute the command in VB.Net ?

     

    Isolation Levels explained by Kendra Little

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • It happens for a particular SELECT query, but the error doesn't occur consistently,it's generated randomly.

  • Does the query contain variables or parameters?


  • I am using the  read committed isolation level to execute the command

  • the query does not contain any variables or parameters

  • No . im not using Prepare()  statement

    My VB.NET code is in the below format


    Dim command As New SqlCommand(query, connection)
    command.ExecuteReader()
  • This was removed by the editor as SPAM

  • I am running out of ideas.

    As this happens for only one query, there must be something about that query which is different from all the others. Is there anything special about it, either in terms of how it is structured or how it is executed?


  • No , a normal select query with few where conditions followed by a ordey by clause

  • OK, I'm done. Please post back with details when you manage to resolve this – it may help others in future.


Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic. Login to reply