Solved

"Connect Timeout" doesn't have effect

Posted on 2008-10-16
3
320 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

18 Experts available now in Live!

Get 1:1 Help Now