ConnectionTimeout

  • Thread starter Thread starter BVM
  • Start date Start date
B

BVM

Hi:

Do you know how to change Connection timeout time? By default it's 15s, Now I want to change it to 30s. However SqlConnection.ConnectionTimeout is read only. What should I do?

Also if the SQL query is to long and need several minutes to finish, is there a way to make timeout time longer?

Thanks,

Dennis Huang
 
Hi

Change your connection string to include connect timeout.
Try this connection string:

public void CreateSqlConnection()
{
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = "Persist Security
Info=False;Integrated
Security=SSPI;database=northwind;server=mySQLServer;Connec
t Timeout=30";
myConnection.Open();
}

HTH
Ravikanth[MVP]

-----Original Message-----
Hi:

Do you know how to change Connection timeout time? By
default it's 15s, Now I want to change it to 30s. However
SqlConnection.ConnectionTimeout is read only. What should
I do?
Also if the SQL query is to long and need several
minutes to finish, is there a way to make timeout time
longer?
 
Dennis, you can change the Connection Timeout property in your Connection
string. Just set tthe value to whatever you want it to be. That will then
change the ConnectionTimeout property on your SqlConnection object.

--
Greg Ewing [MVP]
http://www.citidc.com

Hi:

Do you know how to change Connection timeout time? By default it's 15s, Now
I want to change it to 30s. However SqlConnection.ConnectionTimeout is read
only. What should I do?

Also if the SQL query is to long and need several minutes to finish, is
there a way to make timeout time longer?

Thanks,

Dennis Huang
 
Hi,

In your case, you should consider setting the CommandTimeout property of the command object instead. ConnectionTimeout is a timeout value for establishing a connection, not executing commands.
BTW, to you can set the connection timeout as a part of the connection string.
For eg: "Database=northwind;server=myServer;Connect Timeout=30;Integrated Security=SSPI"

--
HTH,
Manoj G [.NET MVP]
http://www15.brinkster.com/manoj4dotnet

Hi:

Do you know how to change Connection timeout time? By default it's 15s, Now I want to change it to 30s. However SqlConnection.ConnectionTimeout is read only. What should I do?

Also if the SQL query is to long and need several minutes to finish, is there a way to make timeout time longer?

Thanks,

Dennis Huang
 
And don't set it to zero (ie unlimited). Unfortunately, it currently really means ZERO.

HTH,

--
Greg Low (MVP)
MSDE Manager SQL Tools
www.whitebearconsulting.com

Hi,

In your case, you should consider setting the CommandTimeout property of the command object instead. ConnectionTimeout is a timeout value for establishing a connection, not executing commands.
BTW, to you can set the connection timeout as a part of the connection string.
For eg: "Database=northwind;server=myServer;Connect Timeout=30;Integrated Security=SSPI"

--
HTH,
Manoj G [.NET MVP]
http://www15.brinkster.com/manoj4dotnet

Hi:

Do you know how to change Connection timeout time? By default it's 15s, Now I want to change it to 30s. However SqlConnection.ConnectionTimeout is read only. What should I do?

Also if the SQL query is to long and need several minutes to finish, is there a way to make timeout time longer?

Thanks,

Dennis Huang
 
Back
Top