Skip to Content

Databases and timeout

Working with databases sometimes require to change default sql statement execution timeout. But in most of cases programmers miss this value with database connection's timeout.

ADO.NET

In ADO.NET every ADO.NET driver connection class is derived from IDbConnection interface, same as every ADO.NET command is derived from IDbCommand interface.

IDbConnection.ConnectionTimeout - The time (in seconds) to wait for a connection to open. The default value is determined by the specific type of connection that you are using.

IDbCommand.CommandTimeout - The time in seconds to wait for the command to execute.

 

ADO

ADODB.Connection.ConnectionTimeout - value that indicates, in seconds, how long to wait for the connection to open. Default is 15.

ADODB.Connection.CommandTimeout - value that indicates, in seconds, how long to wait for a command to execute. Default is 30.

 

Connection string

Timeout also can be specified in connection string, more info here: http://www.connectionstrings.com/