There are two types of timeout: ConnectionTimeout and CommandTimeout :
ConnectionTimeout Determines the maximum timeout for your application to establish a connection to your server.
CommandTimeout : The maximum time to execute a command.
Make sure you set both options. In the Team :
command.CommandTimeout = 300;
Note. This can be implemented in the Selecting
event if your command is part of a DataSource. e.command.CommandTimeout = 0;
A value of 0
means endless waiting.
And the connection string :
SqlConnectionStringBuilder cs = new SqlConnectionStringBuilder(connectionString); cs.ConnectTimeout = 300;
Or:
<add name="MyConnectionString" connectionString="Data Source=.\SQLEXPRESS; Database=MyDB; Integrated Security=True;Pooling=True;connection timeout=30" providerName="System.Data.SqlClient" />
Note Try setting the connection string timeout worldwide, possibly in your configuration file.
source share