Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. (http://www.velocityreviews.com/forums/t79670-timeout-expired-the-timeout-period-elapsed-prior-to-obtaining-a-connection-from-the-pool-this-may-have-occurred-because-all-pooled-connections-were-in-use-and-max-pool-size-was-reached.html)

Guoqi Zheng 06-03-2004 06:07 PM

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
 
Dear sir,

I keep getting the following errors on one of my sites after clicking for
many times.

Timeout expired. The timeout period elapsed prior to obtaining a connection
from the pool. This may have occurred because all pooled connections were in
use and max pool size was reached.

Below is my code. Any help will be appreciated.

Dim objReader As SqlDataReader

Dim strConnection As String =
System.Configuration.ConfigurationSettings.AppSett ings("strConnect")

Dim myConnection As SqlConnection = New SqlConnection(strConnection)

Dim myCommand As New SqlCommand("MyProc_XXXX", myConnection)

myCommand.CommandType = CommandType.StoredProcedure

Dim objPara1 As New SqlParameter("@msgId", SqlDbType.Int, 4)

myCommand.Parameters.Add(objPara1)

objPara1.Direction = ParameterDirection.Input

objPara1.Value = MsgId

' Open the connection.

myConnection.Open()

objReader = myCommand.ExecuteReader()



MsgFull.DataSource = objReader

MsgFull.DataBind()

objReader.Close()

objReader = Nothing

myConnection.Close()

myConnection = Nothing


--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com




Marina 06-03-2004 06:10 PM

Re: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
 
This typically happens when connections are not closed after they are used.
Perhaps you have other pieces of code running that do this.

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:OeTQPWZSEHA.3476@tk2msftngp13.phx.gbl...
> Dear sir,
>
> I keep getting the following errors on one of my sites after clicking for
> many times.
>
> Timeout expired. The timeout period elapsed prior to obtaining a

connection
> from the pool. This may have occurred because all pooled connections were

in
> use and max pool size was reached.
>
> Below is my code. Any help will be appreciated.
>
> Dim objReader As SqlDataReader
>
> Dim strConnection As String =
> System.Configuration.ConfigurationSettings.AppSett ings("strConnect")
>
> Dim myConnection As SqlConnection = New SqlConnection(strConnection)
>
> Dim myCommand As New SqlCommand("MyProc_XXXX", myConnection)
>
> myCommand.CommandType = CommandType.StoredProcedure
>
> Dim objPara1 As New SqlParameter("@msgId", SqlDbType.Int, 4)
>
> myCommand.Parameters.Add(objPara1)
>
> objPara1.Direction = ParameterDirection.Input
>
> objPara1.Value = MsgId
>
> ' Open the connection.
>
> myConnection.Open()
>
> objReader = myCommand.ExecuteReader()
>
>
>
> MsgFull.DataSource = objReader
>
> MsgFull.DataBind()
>
> objReader.Close()
>
> objReader = Nothing
>
> myConnection.Close()
>
> myConnection = Nothing
>
>
> --
> Kind regards
>
> Guoqi Zheng
> guoqi AT meetholland dot com
> Http://www.meetholland.com
>
>
>




Guoqi Zheng 06-03-2004 06:22 PM

Re: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
 
Thanks for your reply,

I actually really can not find out where I didn't close the connection.

The only Other piece of code which used the connection is below. Do you know
what should I do with it?


Private Function GetMaxPageNr(ByVal fGroupId As Integer, ByVal fPageSize As
Integer) As Integer

Dim ReturnInt As Integer

Dim strConnection As String =
System.Configuration.ConfigurationSettings.AppSett ings("strConnect")

Dim myConnection As SqlConnection = New SqlConnection(strConnection)

Dim myCommand As New SqlCommand("MyProc_TotalPages", myConnection)

myCommand.CommandType = CommandType.StoredProcedure

Dim objPara1 As New SqlParameter("@GroupId", SqlDbType.Int, 4)

myCommand.Parameters.Add(objPara1)

objPara1.Direction = ParameterDirection.Input

objPara1.Value = fGroupId

Dim objPara2 As New SqlParameter("@PageSize", SqlDbType.Int, 4)

myCommand.Parameters.Add(objPara2)

objPara2.Direction = ParameterDirection.Input

objPara2.Value = fPageSize

' for output parameters.

Dim objOutputPara As New SqlParameter("@r", SqlDbType.Int, 4)

myCommand.Parameters.Add(objOutputPara)

objOutputPara.Direction = ParameterDirection.Output

' Open the connection.

myConnection.Open()

myCommand.ExecuteReader()

ReturnInt = objOutputPara.Value

Return ReturnInt

myConnection.Close()

myConnection = Nothing

End Function


--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Marina" <someone@nospam.com> wrote in message
news:e6vSNYZSEHA.1372@TK2MSFTNGP10.phx.gbl...
> This typically happens when connections are not closed after they are

used.
> Perhaps you have other pieces of code running that do this.
>




Marina 06-03-2004 06:27 PM

Re: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
 
Well, there is your problem:

You have a return statement to return ReturnInt, before you close the
connection. The function exits before the connection is closed - hence the
connection leak.

You should put everything in a try/catch/finally, with the connection being
closed in the Finally to ensure that it always gets closed no matter what.

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:uo9wHfZSEHA.3012@tk2msftngp13.phx.gbl...
> Thanks for your reply,
>
> I actually really can not find out where I didn't close the connection.
>
> The only Other piece of code which used the connection is below. Do you

know
> what should I do with it?
>
>
> Private Function GetMaxPageNr(ByVal fGroupId As Integer, ByVal fPageSize

As
> Integer) As Integer
>
> Dim ReturnInt As Integer
>
> Dim strConnection As String =
> System.Configuration.ConfigurationSettings.AppSett ings("strConnect")
>
> Dim myConnection As SqlConnection = New SqlConnection(strConnection)
>
> Dim myCommand As New SqlCommand("MyProc_TotalPages", myConnection)
>
> myCommand.CommandType = CommandType.StoredProcedure
>
> Dim objPara1 As New SqlParameter("@GroupId", SqlDbType.Int, 4)
>
> myCommand.Parameters.Add(objPara1)
>
> objPara1.Direction = ParameterDirection.Input
>
> objPara1.Value = fGroupId
>
> Dim objPara2 As New SqlParameter("@PageSize", SqlDbType.Int, 4)
>
> myCommand.Parameters.Add(objPara2)
>
> objPara2.Direction = ParameterDirection.Input
>
> objPara2.Value = fPageSize
>
> ' for output parameters.
>
> Dim objOutputPara As New SqlParameter("@r", SqlDbType.Int, 4)
>
> myCommand.Parameters.Add(objOutputPara)
>
> objOutputPara.Direction = ParameterDirection.Output
>
> ' Open the connection.
>
> myConnection.Open()
>
> myCommand.ExecuteReader()
>
> ReturnInt = objOutputPara.Value
>
> Return ReturnInt
>
> myConnection.Close()
>
> myConnection = Nothing
>
> End Function
>
>
> --
> Kind regards
>
> Guoqi Zheng
> guoqi AT meetholland dot com
> Http://www.meetholland.com
>
> "Marina" <someone@nospam.com> wrote in message
> news:e6vSNYZSEHA.1372@TK2MSFTNGP10.phx.gbl...
> > This typically happens when connections are not closed after they are

> used.
> > Perhaps you have other pieces of code running that do this.
> >

>
>




Guoqi Zheng 06-03-2004 06:39 PM

Re: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
 
Thanks for your quick reply, will try it..


--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Marina" <someone@nospam.com> wrote in message
news:%234QjzhZSEHA.3580@TK2MSFTNGP09.phx.gbl...
> Well, there is your problem:
>
> You have a return statement to return ReturnInt, before you close the
> connection. The function exits before the connection is closed - hence the
> connection leak.
>
> You should put everything in a try/catch/finally, with the connection

being
> closed in the Finally to ensure that it always gets closed no matter what.
>





All times are GMT. The time now is 01:42 PM.

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