Solved

"Connect Timeout" doesn't have effect

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting max record but maybe not use Group BY 2 27
SQL Server Insert where not exists 24 41
help with regular expression to search string 6 24
.NET 2008 VB and C# 6 27
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

774 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