By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

Time out errors

P: n/a
Rob
VB.net 2005 Windows app... makes calls to 2005 SQL server... sometimes I get
a Timeout error, other times I do not...

What is the best way to handle timeout errors ?
1. How to increase the timeout - from the app it appears that the property
is "read -only" ? So must it be set at the server from within SQL
Management studio ? If so how ?

2. How would you implement a "try again" method ?

Thanks !
Jul 29 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"Rob" <ro***@yahoo.comwrote in message
news:Mq******************************@comcast.com. ..
VB.net 2005 Windows app... makes calls to 2005 SQL server... sometimes I
get a Timeout error, other times I do not...

What is the best way to handle timeout errors ?
1. How to increase the timeout - from the app it appears that the property
is "read -only" ? So must it be set at the server from within SQL
Management studio ? If so how ?
Maybe, you have too many connections open, because things are not being
closed properly. The application cannot get another connection and is timing
out, because of existing open connections that were never disposed.

>
2. How would you implement a "try again" method ?
Maybe, you don't want to try again and find out what the problem is, because
it shouldn't be happening.

Jul 29 '07 #2

P: n/a
Rob

Hi,

The code goes something like this.... I am opening, closing, disposing,
then opening, closing, disposing, again.... maybe as many as 10 times in a
row back to back.... could this be a problem ?

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd as New SqlCommand
cmd = cnn.CreateCommand
' code to execute a stored proc
cmd.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd.Dispose()
cmd=nothing

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd2 as New SqlCommand
cmd2 = cnn.CreateCommand
' code to execute a stored proc
cmd2.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd2.Dispose()
cmd2=nothing

Thanks !


"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:O3**************@TK2MSFTNGP04.phx.gbl...
>
"Rob" <ro***@yahoo.comwrote in message
news:Mq******************************@comcast.com. ..
>VB.net 2005 Windows app... makes calls to 2005 SQL server... sometimes I
get a Timeout error, other times I do not...

What is the best way to handle timeout errors ?
1. How to increase the timeout - from the app it appears that the
property is "read -only" ? So must it be set at the server from within
SQL Management studio ? If so how ?

Maybe, you have too many connections open, because things are not being
closed properly. The application cannot get another connection and is
timing out, because of existing open connections that were never disposed.

>>
2. How would you implement a "try again" method ?

Maybe, you don't want to try again and find out what the problem is,
because it shouldn't be happening.

Jul 29 '07 #3

P: n/a

"Rob" <ro***@yahoo.comwrote in message
news:4t******************************@comcast.com. ..
>
Hi,

The code goes something like this.... I am opening, closing, disposing,
then opening, closing, disposing, again.... maybe as many as 10 times in a
row back to back.... could this be a problem ?

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd as New SqlCommand
cmd = cnn.CreateCommand
' code to execute a stored proc
cmd.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd.Dispose()
cmd=nothing

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd2 as New SqlCommand
cmd2 = cnn.CreateCommand
' code to execute a stored proc
cmd2.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd2.Dispose()
cmd2=nothing

Thanks !
I can't say that it is. What you need to do is go to SQL Server 2005 using
the Query Analyzer equivalent that can be used on SQL Server 2000 and use
the the SQL Server Stored Procedure utility (I can't think of the Store
Procedure name) that tells you the active user-id(s) that are accessing SQL
server.

If you run your program and use that SQL Server utility, and you you see the
user-id the application is using to access SQL Server more than one time,
then you have a problem. The user-id should be showing only once throughout
the running of said application.
If this is in-line code back to back as you say, then you open the
connection one time, you execute your SQL commands, close the connection and
dispose of the connection. One connection that stays open until you execute
all the commands and then close the connection.

You use the open and close method when in-line back to back code is not
being used, with SQL Server access being done in different areas of the
code, like in different subroutines being called, as an example with their
own code to access SQl Server.
..

Jul 30 '07 #4

P: n/a
if you use vs.NET 2005 you would better use a using construct
Using cnn As New SqlConnection

Using cmd As New SqlCommand

End Using

End Using
"Rob" wrote:
>
Hi,

The code goes something like this.... I am opening, closing, disposing,
then opening, closing, disposing, again.... maybe as many as 10 times in a
row back to back.... could this be a problem ?

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd as New SqlCommand
cmd = cnn.CreateCommand
' code to execute a stored proc
cmd.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd.Dispose()
cmd=nothing

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd2 as New SqlCommand
cmd2 = cnn.CreateCommand
' code to execute a stored proc
cmd2.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd2.Dispose()
cmd2=nothing

Thanks !


"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:O3**************@TK2MSFTNGP04.phx.gbl...

"Rob" <ro***@yahoo.comwrote in message
news:Mq******************************@comcast.com. ..
VB.net 2005 Windows app... makes calls to 2005 SQL server... sometimes I
get a Timeout error, other times I do not...

What is the best way to handle timeout errors ?
1. How to increase the timeout - from the app it appears that the
property is "read -only" ? So must it be set at the server from within
SQL Management studio ? If so how ?
Maybe, you have too many connections open, because things are not being
closed properly. The application cannot get another connection and is
timing out, because of existing open connections that were never disposed.

>
2. How would you implement a "try again" method ?
Maybe, you don't want to try again and find out what the problem is,
because it shouldn't be happening.


Jul 30 '07 #5

P: n/a
Rob
Using the Activity monitor in SQL 2005, it looks like it is creating more
than one connection per user... it appears that the Dispose may not actually
killing the process id... any idea why ?

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:eR**************@TK2MSFTNGP04.phx.gbl...
>
"Rob" <ro***@yahoo.comwrote in message
news:4t******************************@comcast.com. ..
>>
Hi,

The code goes something like this.... I am opening, closing, disposing,
then opening, closing, disposing, again.... maybe as many as 10 times in
a row back to back.... could this be a problem ?

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd as New SqlCommand
cmd = cnn.CreateCommand
' code to execute a stored proc
cmd.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd.Dispose()
cmd=nothing

cnn = New SqlConnection(strConnection)
cnn.Open

Dim cmd2 as New SqlCommand
cmd2 = cnn.CreateCommand
' code to execute a stored proc
cmd2.ExecuteNonQuery()

cnn.close()
cnn.Dispose()

cmd2.Dispose()
cmd2=nothing

Thanks !

I can't say that it is. What you need to do is go to SQL Server 2005 using
the Query Analyzer equivalent that can be used on SQL Server 2000 and use
the the SQL Server Stored Procedure utility (I can't think of the Store
Procedure name) that tells you the active user-id(s) that are accessing
SQL server.

If you run your program and use that SQL Server utility, and you you see
the user-id the application is using to access SQL Server more than one
time, then you have a problem. The user-id should be showing only once
throughout the running of said application.
If this is in-line code back to back as you say, then you open the
connection one time, you execute your SQL commands, close the connection
and dispose of the connection. One connection that stays open until you
execute all the commands and then close the connection.

You use the open and close method when in-line back to back code is not
being used, with SQL Server access being done in different areas of the
code, like in different subroutines being called, as an example with their
own code to access SQl Server.
.

Jul 30 '07 #6

P: n/a

"Rob" <ro***@yahoo.comwrote in message
news:Ho******************************@comcast.com. ..
Using the Activity monitor in SQL 2005, it looks like it is creating more
than one connection per user... it appears that the Dispose may not
actually killing the process id... any idea why ?

No I don't know why. Maybe you just need to use the ADO.NET USING statement
instead.

http://www.pluralsight.com/blogs/fri...4/28/7834.aspx

Like I said, if all this is back to back SQL access with in-line code
statements in one procedure, then you only need one connection statement
and one cnn.Open for all of it. And you close it when done or use the USING
statement.
Jul 30 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.