SqlConnection - Timeout Property is read-only?

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I'd like to change the SqlConnection timeout propery from the default 15
seconds down to 4 or less. How can I change it? I have been unable to find
an example of a connection string that would allow me to override this.

Thanks in advance for your help.

Mark
 
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref4/html/P_System_Data_SqlClient_SqlConnection_ConnectionString.htm

It took some time to find it (sadly) but it's there. You can set the
Connection Timeout in the ConnectionString property of the SqlConnection
object. Why do you need to change this? What problem are you trying to
solve?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
THanks but that's a read-only property of the SqlConnection object. My hope
is that someone will know the syntax for adding the property directly to the
connection string.

In the event that our app can't find a server in less than 4 seconds, that's
a fantastic sign something is wrong, and there is no sense in letting the
app look around for 15 seconds if it can't find it in the first 4 or less.

Thanks again.

Mark
 
¤ THanks but that's a read-only property of the SqlConnection object. My hope
¤ is that someone will know the syntax for adding the property directly to the
¤ connection string.
¤
¤ In the event that our app can't find a server in less than 4 seconds, that's
¤ a fantastic sign something is wrong, and there is no sense in letting the
¤ app look around for 15 seconds if it can't find it in the first 4 or less.
¤

Try either Connect Timeout or Connection Timeout.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Ah, I pointed to the ConnectionString property which is NOT read-only. You
need to set the Connection Timeout key in the ConnectionString prior to
opening the Connection to change the timeout.


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Both you and Bill claim that the Connection timeout property can be written
to. Looking at VS.NET 2003 class library documentation, I find the
following:

SqlConnection Properties:
ConnectionTimeout Property:
Gets the time to wait while trying to establish a connection before
terminating the attempt and generating an error.

Those properties that are read/write are listed as "Gets or Sets blah blah
blah."

Am I missing something here? Thanks again.

Mark
 
¤ Both you and Bill claim that the Connection timeout property can be written
¤ to. Looking at VS.NET 2003 class library documentation, I find the
¤ following:
¤
¤ SqlConnection Properties:
¤ ConnectionTimeout Property:
¤ Gets the time to wait while trying to establish a connection before
¤ terminating the attempt and generating an error.
¤
¤ Those properties that are read/write are listed as "Gets or Sets blah blah
¤ blah."
¤
¤ Am I missing something here? Thanks again.

I think so. ;-)

Below is an example for SQL Express that uses the "Connection Timeout" argument:

Server=.\\SQLEXPRESS ;Integrated Security=SSPI;Connection Timeout=5


Paul
~~~~
Microsoft MVP (Visual Basic)
 
NO WE DON'T. Both Paul and I say it must be changed via the
ConnectionString. This is VERY basic and we assumed (apparently incorrectly)
that you understand when we talk about a ConnectionString that we mean you
need to set the ConnectionString.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top