Solved

"Connect Timeout" doesn't have effect

Posted on 2008-10-16
3
323 Views
Last Modified: 2013-12-17
Hello, experts.
I have an SQL Server 2005 Express Edition, wich I access from my C# 2008 application. The table I work with is pretty big and it takes more than 30 seconds to execute some of the stored procedures, so I set "Connect Timeout=300" in a connection string. It doesn't have any effect, though: after 30 seconds the ExecuteReader command throws an exception "Timeout expired". When I execute the stored procedure from Management Studio, it completes successfully (takes about a minute), and it worked fine from code when the table was smaller, so I'd say the error message is correct and it looks like there is some setting elsewhere, which limits the timeout to 30 seconds.
Does anybody have a clue where it might be?
0
Comment
Question by:nebfis
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 250 total points
ID: 22731494
Hello nebfis,

You don't want to be setting the "CONNECT" timeout, this does what it says on the tin! If the CONNECTION has not been made in the specified time then it stops trying. It does not affect the time for the command itself to execute. For this you need to set the .CommandTimeout property of the sqlCommand object to a suitable period, perhaps 90 seconds to allow a bit of breathing space.

Regards,

TimCottee
0
 
LVL 6

Expert Comment

by:mirzas
ID: 22731540
"Connect Timeout" -> this is only used when you are initially connecting to the server.

It just means how long will the client try to connect to the server. Once you have established a connection this has no more effect.
0
 

Author Closing Comment

by:nebfis
ID: 31506754
Thank you, TimCottee. You were absolutely right. I tried it and it works flawlessly.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 48
SSL https .net web site force redirect 3 38
Automated testing suggestions? 2 29
Query to return total 6 8
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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

22 Experts available now in Live!

Get 1:1 Help Now