Re: Time out errors

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




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. Arnold@xxxxxxxxxx> wrote in message
news:O3zckLi0HHA.4816@xxxxxxxxxxxxxxxxxxxxxxx

"Rob" <robc1@xxxxxxxxx> wrote in message
news:Mqudnf6l-_FENjHbnZ2dnUVZ_rSinZ2d@xxxxxxxxxxxxxx
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.


.



Relevant Pages

  • Re: Too Many Processes?
    ... > uses stored procedures extensively to access the data. ... I've been closing my connections after executing any data ... As long as you are correctly closing AND disposing of your objects when ...
    (microsoft.public.sqlserver.programming)
  • Re: Threading and a database connections.
    ... Are you closing your connections in the Finally block? ... If you are disposing some objects in the Finally block, ... Update commands would always apply a lock on the table, however, ...
    (microsoft.public.dotnet.languages.vb)
  • Let the adapter handle the connection?
    ... I've just read here that the adapter will handle the opening and ... closing of the connections. ... My assumption is that the code above is still just opening one ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ADO high virtual memory usage
    ... Where are you opening and closing your connections? ... Is that a static array? ...
    (microsoft.public.data.ado)
  • Re: Somerset and Dorset tears
    ... Couldn't connections have been built? ... opening up new journey opportunities but closing the most ...
    (uk.railway)