Solved

Change connectiontimeout in ADO.NET

Posted on 2008-11-01
3
1,886 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
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

26 Experts available now in Live!

Get 1:1 Help Now