Multiple Simultaneous SQL Connection Timeouts In Multithreaded Windows Service

前端 未结 5 558
一生所求
一生所求 2020-12-25 12:37

I have a multithreaded Windows Service I\'ve developed with VS 2010 (.NET 4.0) which can have anywhere from a few to a few dozen threads, each retrieving data from a slow se

5条回答
  •  天涯浪人
    2020-12-25 13:13

    Connection timeout is a different thing than command timeout. Command timeout applies to situation when you have connection established, but due to some internal reasons server cannot return any results within required time. Default command timeout is 30 seconds. http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

    Try to specify connection timeout in the connection string. Default value is 15 seconds what may be the reason of the issue you see. You can also specify connection timeout in code: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx

提交回复
热议问题