Solved

"Connect Timeout" doesn't have effect

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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