Solved

Change connectiontimeout in ADO.NET

Posted on 2008-11-01
3
1,892 Views
Last Modified: 2013-12-17
Hi experts!

I have project with C#  , WindowsForms and Framework 2.0 with VS2008. I open connection to SQL Server 2005 and want to set different (smaller ) ConnectionTimeout . This property is read only, do I have other properties or way to chage it?  It is very borrow to wait 30 sec. In LAN connection&
0
Comment
Question by:dvplayltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22858321
use this

mycon.CommandTimeout = ... set your time here

mycon is connection object
0
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 500 total points
ID: 22858336
The connection string http://www.connectionstrings.com/?carrier=sqlserver2005 has an optional property for "Connection Timeout" http://articles.techrepublic.com.com/5100-10878_11-6084879.html# which you would set as in the example below (the actual connection string will depend on your type of connection).

CommandTimeout http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx is different than ConnectionTimeout http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;Connection Timeout=10;

Open in new window

0
 

Author Closing Comment

by:dvplayltd
ID: 31512369
Thank you very much for you time!I get answer to other me question - how to change connection port for SQL Server ( I will work with SQL Server with realIP via Internet).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question