I am using VSTS 2008 + ADO.Net + C# + .Net 3.5 + SQL Server 2008. I am using ADO.Net at client side to connect to database server to execute a store procedure, then return r
In sqlconnection class, there is a property by name ConnectionTimeout.
This cannot be directly used to set desired connection timeout value as it is readonly i.e. only "get" is implemented & "set" is not implemented on this property.So we have to use keyword "Connection Timeout" in the connection string itself & set the desired value.
exi:
Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=SSPI;Connection Timeout=30";(30 means 30 seconds)
30 seconds is the maximum time given to establish connection to the server(like 172.160.0.2 OR something like ADMINISTRATOR\\SQLEXPRESS).If it could not immediately establish connection to server , then it will try up to 30 seconds.
If server is valid & is able to connect to server & if database name or login credentials are invalid , then this timeout won't be applicable.It immediately throws exception for invalid credentials or database