473,473 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to change a SQL connection timeout

I have used the visual designer to create a series of DataGridViews
populated from SQLServer data.
A typical call is:

myCountsTableAdapter.Fill(myDataSet.myCounts);

My application actually connects to different systems during a run; on
some of these the default timeout is adequate, but on one system I get an
SQL exception that simply reports "Timeout expired". The default timeout
shows as "15" using this line of code.

Console.WriteLine("timeout = "
+ myCountsTableAdapter.Connection.ConnectionTimeout) ;

But this property is read-only; how can I change it?
May 8 '06 #1
6 59901

"michael sorens" <m_********@community.nospam> wrote in message
news:op***************@spo-cont-2-dt.itron.com...
|I have used the visual designer to create a series of DataGridViews
| populated from SQLServer data.
| A typical call is:
|
| myCountsTableAdapter.Fill(myDataSet.myCounts);
|
| My application actually connects to different systems during a run; on
| some of these the default timeout is adequate, but on one system I get an
| SQL exception that simply reports "Timeout expired". The default timeout
| shows as "15" using this line of code.
|
| Console.WriteLine("timeout = "
| + myCountsTableAdapter.Connection.ConnectionTimeout) ;
|
| But this property is read-only; how can I change it?

Set the timeout in your connection string....

...., Connection Timeout=30,...

Check msdn for other ConnectionString keywords.

Willy.

May 8 '06 #2
I was able to change the Connection Timeout as you suggested--confirmed
with a WriteLine--yet my application still threw a SQLException with a
timeout, even going up to 120 seconds. Running the query in SqlServer
Express takes only 30 to 35 seconds every time. Is there a second timeout
value that might be causing my problem?

On Mon, 08 May 2006 11:30:08 -0700, Willy Denoyette [MVP]
<wi*************@telenet.be> wrote:

"michael sorens" <m_********@community.nospam> wrote in message
news:op***************@spo-cont-2-dt.itron.com...
|I have used the visual designer to create a series of DataGridViews
| populated from SQLServer data.
| A typical call is:
|
| myCountsTableAdapter.Fill(myDataSet.myCounts);
|
| My application actually connects to different systems during a run; on
| some of these the default timeout is adequate, but on one system I get
an
| SQL exception that simply reports "Timeout expired". The default
timeout
| shows as "15" using this line of code.
|
| Console.WriteLine("timeout = "
| + myCountsTableAdapter.Connection.ConnectionTimeout) ;
|
| But this property is read-only; how can I change it?

Set the timeout in your connection string....

..., Connection Timeout=30,...

Check msdn for other ConnectionString keywords.

Willy.


May 8 '06 #3
michael sorens wrote:
I was able to change the Connection Timeout as you suggested--confirmed
with a WriteLine--yet my application still threw a SQLException with a
timeout, even going up to 120 seconds. Running the query in SqlServer
Express takes only 30 to 35 seconds every time. Is there a second
timeout value that might be causing my problem?

There is a connection timeout and a command timeout.
Connection Timeout: the time it takes before a connection attempt will
timeout.
Command Timeout: the time it takes before command processing will timeout.

JB
<...>
May 8 '06 #4
I agree with JB, that you have to set the CommandTimeout of the
DataAdapter.SelectCommand.CommandTimeout property. But since you're using a
TableAdapter generated by the designer, I think you have to modify the
designer generated code.

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 10 '06 #5
Aha, the evidence pointed me to a separate timeout for connection vs.
command; thanks for the confirmation! I took a look through the generated
code to try to identify where to access this CommandTimeout but it is not
terribly obvious. Any further hints...?

On Mon, 08 May 2006 19:02:42 -0700, Kevin Yu [MSFT]
<v-****@online.microsoft.com> wrote:
I agree with JB, that you have to set the CommandTimeout of the
DataAdapter.SelectCommand.CommandTimeout property. But since you're
using a
TableAdapter generated by the designer, I think you have to modify the
designer generated code.

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 10 '06 #6
I just found a chunk of code to do precisely this
(http://www.codeproject.com/csharp/Ta...ndTimeout.asp). It
almost worked "as is" -- I had to change "_commandCollection" to
"CommandCollection" and then it worked flawlessly.

Thanks again for guiding me in the right direction!
May 10 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tperovic | last post by:
Hi, I have an application that uses ADO & VBA to connect to SQL Server 2000 periodically like this: Dim conn As ADODB.Connection Set conn = New ADODB.Connection conn.ConnectionTimeout = 1...
7
by: C# beginner | last post by:
I'm struggling with a timeout problem today. ConnectionString = "Integrated Security=true;Database=MyDatabase;Data Source=(local); Connection Timeout = 180;"; My connection string is set as...
4
by: Shachar | last post by:
Hi All, When I call a web service on the IIS 5 or 6 I see the connection count increase by 1 user, but after a minute the connection is close, connection count decrease by 1 user, I see it...
0
by: Christopher H. Laco | last post by:
I'm in a strange situation. I have a dataset that uses it own connection string from MySettings. All is well. This thing works in .NET just dandy. If I reference this dataset from another...
3
by: Amar Gaikwad | last post by:
Hi All, I want to read the contents (only the filenames) from the ftp server. The code which I have throws connection timeout exception :: "A connection attempt failed because the connected...
4
by: rowan | last post by:
I'm writing a driver in Python for an old fashioned piece of serial equipment. Currently I'm using the USPP serial module. From what I can see all the serial modules seem to set the timeout when...
3
by: =?Utf-8?B?QXho?= | last post by:
Is there a limitation on the number of (sequential) opened connection for SQL Server User Instances? The following method will run to about the 240th iteration then will receive a timeout...
8
by: Charlotte | last post by:
Hi, the connection timeout in my IIS (webserver in a LAN) is now 600 (600 seconds = 10 minutes) I want to set the connectiontimeout to 3600 (1 hour) or may I set the timeout for 36000...
4
by: mohana123 | last post by:
HI, While running an asp.net application in other than server system it gives the error of connection timeout. In this case as i need to change the IIS configuration? kindly provide the solution...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.