Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all i have created small windows application,my application contains 2 connection string
if the 1 st connection available it will connect to that database and save the data,else it will connect to the 2nd connect string and save the data,
in my case, if my 1st connection fails, it taking too long time to come back and read my 2nd connection string

how to solve this issue
Posted

1 solution

You can specify a Connection Timeout [^]property, which is the amount of time to wait for connection to open.

The default is 15 seconds, so you may want to change that for your needs

Edit: See examples here

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring%28v=vs.71%29.aspx[^]


C#
[C#]
public void CreateSqlConnection()
 {
    SqlConnection myConnection = new SqlConnection();
    myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";
    myConnection.Open();
 }
 
Share this answer
 
v2
Comments
sameertm 21-Mar-12 7:15am    
Can you please tell me where i need to specify that seconds in the below connection string :
server_connectionstring = "Persist Security Info=False;Integrated Security=False;Server=192.168.100.15;initial catalog=ProductionPDA;user id=smt;password=123456;"
Dylan Morley 21-Mar-12 7:25am    
see my edit

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900