Connection timeout in sql connection string

mkg
mkg
2 Points
1 Posts

Hi,

Connection timeout in sql connection string

Views: 8146
Total Answered: 1
Total Marked As Answer: 0
Posted On: 30-Apr-2015 03:24

Share:   fb twitter linkedin
Answers
Brian
Brian
Participant
536 Points
73 Posts
     

Hi,

You can set connection timeout in connection string as:

;Connection Timeout=30
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=servername;Initial Catalog=databasename;Connection Timeout=30;User ID=userid;Password=*****" providerName="System.Data.SqlClient"/>
</connectionStrings>

The value set in the Connection Timeout property is a time expressed in seconds. If this property is not set, the value for the connection is the default value (15 seconds).

Moreover, setting the timeout value to 0, your attempt to connect waits an infinite time and it should be avoided in a ConnectionString because an attempt to connect waits indefinitely.

Posted On: 30-Apr-2015 03:47
banner

Blog

Active User (2)

 Log In to Chat