Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Help with connection pooling - connections get closed but remain active (http://www.velocityreviews.com/forums/t101517-help-with-connection-pooling-connections-get-closed-but-remain-active.html)

caroh@orange.net 04-27-2005 04:47 PM

Help with connection pooling - connections get closed but remain active
 
Can anyone see whats wrong with this code:

The connections are remaining live in the database: and causing
"Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool" errors.

Try
'open the connection
myConnection.Open()
'run the query
myCommand.ExecuteNonQuery()
Catch ex As SqlException

Finally
'close connection
myConnection.Close()

End Try

'Check to see if the service is restricted
If
myCommand.Parameters("@AccessRestrictionsSupported ").Value.Equals(1)
Then
Return True 'service is restricted
'myConnection.Close()
Else
Return False 'service not restricted
'myConnection.Close()
End If

myConnection.Close()

Any help/suggestions very much appreciated

Thanks!!


Gabriel Lozano-Morán 04-27-2005 05:11 PM

Re: Help with connection pooling - connections get closed but remain active
 
close the connection immediatly after the ExecuteNonQuery() method call. You
don't need the myConnection.Close() at the bottom since the finally block
will always be executed. When you close a connection it returns to the
connection pool where it will be destroyed after an idle period of 4 to 7.5
minutes.

Where do you exactly get the time-outs?

Gabriel Lozano-Morán

<caroh@orange.net> wrote in message
news:1114620447.639728.84330@z14g2000cwz.googlegro ups.com...
> Can anyone see whats wrong with this code:
>
> The connections are remaining live in the database: and causing
> "Timeout expired. The timeout period elapsed prior to obtaining a
> connection from the pool" errors.
>
> Try
> 'open the connection
> myConnection.Open()
> 'run the query
> myCommand.ExecuteNonQuery()
> Catch ex As SqlException
>
> Finally
> 'close connection
> myConnection.Close()
>
> End Try
>
> 'Check to see if the service is restricted
> If
> myCommand.Parameters("@AccessRestrictionsSupported ").Value.Equals(1)
> Then
> Return True 'service is restricted
> 'myConnection.Close()
> Else
> Return False 'service not restricted
> 'myConnection.Close()
> End If
>
> myConnection.Close()
>
> Any help/suggestions very much appreciated
>
> Thanks!!
>




Caro 04-28-2005 02:41 PM

Re: Help with connection pooling - connections get closed but remain active
 
Timeouts when users logon to system.

Checked in enterprise manager - process info and there are lots of
active connections to the stored procedure that this piece of code
executes.

Thanks for your help

Much appreciated

"Gabriel Lozano-Morán" <gabriel.lozano@no-spam.com> wrote in message news:<eNjtDw0SFHA.3684@TK2MSFTNGP10.phx.gbl>...
> close the connection immediatly after the ExecuteNonQuery() method call. You
> don't need the myConnection.Close() at the bottom since the finally block
> will always be executed. When you close a connection it returns to the
> connection pool where it will be destroyed after an idle period of 4 to 7.5
> minutes.
>
> Where do you exactly get the time-outs?
>
> Gabriel Lozano-Morán
>
> <caroh@orange.net> wrote in message
> news:1114620447.639728.84330@z14g2000cwz.googlegro ups.com...
> > Can anyone see whats wrong with this code:
> >
> > The connections are remaining live in the database: and causing
> > "Timeout expired. The timeout period elapsed prior to obtaining a
> > connection from the pool" errors.
> >
> > Try
> > 'open the connection
> > myConnection.Open()
> > 'run the query
> > myCommand.ExecuteNonQuery()
> > Catch ex As SqlException
> >
> > Finally
> > 'close connection
> > myConnection.Close()
> >
> > End Try
> >
> > 'Check to see if the service is restricted
> > If
> > myCommand.Parameters("@AccessRestrictionsSupported ").Value.Equals(1)
> > Then
> > Return True 'service is restricted
> > 'myConnection.Close()
> > Else
> > Return False 'service not restricted
> > 'myConnection.Close()
> > End If
> >
> > myConnection.Close()
> >
> > Any help/suggestions very much appreciated
> >
> > Thanks!!
> >



All times are GMT. The time now is 01:51 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.