问题
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
回答1:
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
回答2:
Try running your SQL query using Microsoft SQL Server Management Studio, and click the "Estimated Execution Plan" button. This will tell you if you have any indexes missing. Adding the missing indexes should speed up your query.
回答3:
Increase the query timeout. Connection timeout is only on the connection time. Presuming you are using SqlCommand, there is a timeout property in there.
来源:https://stackoverflow.com/questions/6743320/timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation