Solved

Change connectiontimeout in ADO.NET

Posted on 2008-11-01
3
1,883 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
3 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
Comment Utility
use this

mycon.CommandTimeout = ... set your time here

mycon is connection object
0
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 500 total points
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now