Timeout Exception

  • Thread starter Thread starter Norm Dotti
  • Start date Start date
N

Norm Dotti

I'm missing something. While others on this newsgroup have
had unexplained timout exceptions occurring I can't seem
to get them to occur. Perhaps my understanding of how
they're supposed to work is wrong. I've got the following
code. The command takes roughly 50 seconds to execute in
the database yet I never get a timeout exception even
though I've got Timeout specified in the Connection string
and the CommandTimeout property of the Command object. It
simply runs for the 50 seconds and returns happily as if
everything was ok. I've tried various settings for the
Timeout parameter in the Connection string as well as the
CommandTimeout property of the Command object.

Should I be getting an exception? If so, why aren't I? If
not, how do I determine if the database connection has
timed out?



Dim strConnectionString As String = "yada yada;Connect
Timeout=10"
Dim strSQLStatement As String = "SELECT * FROM TABLE"
Try
Dim con As New SqlClient.SqlConnection
(strConnectionString)

Dim cmd As New SqlClient.SqlCommand(strSQLStatement, con)
cmd.CommandTimeout = 5
SqlClient.SqlCommand(strSQLStatement, con)
Dim dstDataSet As New DataSet()
Dim dadDataAdapter As New SqlClient.SqlDataAdapter(cmd)
dadDataAdapter.Fill(dstDataSet)
Catch excSqlExc As System.Data.SqlClient.SqlException
MessageBox.Show(excSqlExc.ToString)
Catch excGeneric As Exception
MessageBox.Show(excGeneric.ToString)
Finally
'Clean up
End Try
 
Fill calls your selectCommand which has commandTimeout set and it will only fail if the response time taken by the server is over commandTimeout
allowed. Fill just could not use the commandTimeout of the selectCommand to control how long it should last .

Visual Basic .NET Team
Jimmy

--------------------
Content-Class: urn:content-classes:message
From: "Norm Dotti" <[email protected]>
Sender: "Norm Dotti" <[email protected]>
References: <[email protected]> <[email protected]>
Subject: RE: Timeout Exception
Date: Thu, 7 Aug 2003 06:41:51 -0700
Lines: 110
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcNc6af7NHNxUXAYT4i6tgFbFQof8A==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.framework.adonet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:57661
NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.framework.adonet

Thanks. The ConnectionTimeout explanation makes sense.
Regarding CommandTimeout, if Fill doesn't make use of it
what does?



Once it's connected, the connectionTimeout does not have
effect on command executions. For
query is processed by the server within 5 seconds, your
commandTimeout setting. CommandTimeout
processed before it throws an exception. You could not
control execution time of your fill by the
to do the Fill and kill it if it does not work as fast as
you want.
confers no rights. Use of included script samples are
subject to the terms specified at
responses to this message are best directed to the
newsgroup/thread from which they originated.


--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 
I'm confused. If the first sentence you're saying (I
think) it will throw a timeout exception "...if the
response time taken by the server is over commandTimeout
allowed." In the second sentence you say "Fill just could
not use the commandTimeout..." Which is it? I guess more
to the point, "How can I make use of commandTimeout if not
with Fill?"

-----Original Message-----
Fill calls your selectCommand which has commandTimeout
set and it will only fail if the response time taken by
the server is over commandTimeout
allowed. Fill just could not use the commandTimeout of
the selectCommand to control how long it should last .
Visual Basic .NET Team
Jimmy
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all
responses to this message are best directed to the
newsgroup/thread from which they originated.
 
In cases, you want the command which has waited for commandTimeout to expire to be terminated due to slow server, slow or broken network connection
that make it impossible to execute. However, sometimes it might take 2 minutes to load all data but as long as it starts loading within your
commandTimeout, it will keep running until it finishes.

Visual Basic Team .NET
Jimmy


--------------------
Content-Class: urn:content-classes:message
From: "Norm Dotti" <[email protected]>
Sender: "Norm Dotti" <[email protected]>
References: <[email protected]> <[email protected]> <04d401c35ce9$a7fdcf70
Subject: RE: Timeout Exception
Date: Fri, 8 Aug 2003 05:48:59 -0700
Lines: 177
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNdq2/2TxduwTj2SIySY9IC5iBwgQ==
Newsgroups: microsoft.public.dotnet.framework.adonet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:57796
NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.framework.adonet

I'm confused. If the first sentence you're saying (I
think) it will throw a timeout exception "...if the
response time taken by the server is over commandTimeout
allowed." In the second sentence you say "Fill just could
not use the commandTimeout..." Which is it? I guess more
to the point, "How can I make use of commandTimeout if not
with Fill?"


set and it will only fail if the response time taken by
the server is over commandTimeout
the selectCommand to control how long it should last .
confers no rights. Use of included script samples are
subject to the terms specified at
responses to this message are best directed to the
newsgroup/thread from which they originated.


--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 
Back
Top