SQLConnection.connectiontimeout

  • Thread starter Thread starter cj
  • Start date Start date
C

cj

MySQLConnection.connectiontimeout() returns 15. I want to drop that to
3, but it is read only. I see you can include the timeout "Connection
Timeout=30" as part of the connection string but I don't necessarily
want it at 3 during the connection--just for queries. Is there a way to
set it after I'm connected or for it not to affect the connection process?
 
Hi Cj,

As for the SqlConnection's Timeout setting, it should be configured through
the "Connection Timeout" attribute in connectionstring, after the
SqlConnection object is created, that property is readonly.

#SqlConnection.ConnectionTimeout Property
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection
..connectiontimeout.aspx

However, if what you want to do is restrict the timeout period of a certain
query or update command's execution, you should use use
SqlCommand.CommandTimeout property to control the command execution timeout:

#SqlCommand.CommandTimeout Property
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.co
mmandtimeout(VS.80).aspx

Also, to make use of this CommandTimeout, you need to turn off "Context
Connection" in the connectionstring(as indicated in the above reference).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top