sql server timeout

SqlConnection.ConnectionTimeout

https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectiontimeout?redirectedfrom=MSDN&view=netframework-4.7.2#System_Data_SqlClient_SqlConnection_ConnectionTimeout

Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.

The time (in seconds) to wait for a connection to open. The default value is 15 seconds.

You can set the amount of time a connection waits to time out by using the Connect Timeout or Connection Timeout keywords in the connection string. A value of 0 indicates no limit, and should be avoided in a ConnectionString because an attempt to connect waits indefinitely.

SqlCommand.CommandTimeout

https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand.commandtimeout?view=netframework-4.7.2

The time in seconds to wait for the command to execute. The default is 30 seconds.

原文地址:https://www.cnblogs.com/chucklu/p/10410982.html