Question

I get the following error upon running a query.

*

System.Data.SqlClient.SqlException: Timeout expired.
The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

*

Is this a connection timeout or command timeout?

TIA

Was it helpful?

Solution

Looks like a command timeout. If you have a connection timeout, you will see from the stack trace that it's thrown from a call to SqlConnection.Open. Any other timeout will be a command timeout.

OTHER TIPS

You will need to post more code as to how you connection and what you are trying to execute. A command timeout propogates to a sqlexception timeout error so it could be.

What is the commmand or query you are trying to run? Once posted we may help optimize it. You can also try to set a timeout period for both the connection and the command object. Increase it and see if it helps.

How long does the query take when run from SSMS?

If fast, then you problem could be a deadlock.

Are you using any transactions? Are you sharing the database with other applications/users?

More info will be very useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top