473,544 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Configur ation.Configura tionSettings.Ap pSettings("strC onnect")

Dim myConnection As SqlConnection = New SqlConnection(s trConnection)

Dim myCommand As New SqlCommand("MyP roc_XXXX", myConnection)

myCommand.Comma ndType = CommandType.Sto redProcedure

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

myCommand.Param eters.Add(objPa ra1)

objPara1.Direct ion = ParameterDirect ion.Input

objPara1.Value = MsgId

' Open the connection.

myConnection.Op en()

objReader = myCommand.Execu teReader()

MsgFull.DataSou rce = objReader

MsgFull.DataBin d()

objReader.Close ()

objReader = Nothing

myConnection.Cl ose()

myConnection = Nothing
--
Kind regards

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

Nov 18 '05 #1
4 23163
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:Oe******** ******@tk2msftn gp13.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.Configur ation.Configura tionSettings.Ap pSettings("strC onnect")

Dim myConnection As SqlConnection = New SqlConnection(s trConnection)

Dim myCommand As New SqlCommand("MyP roc_XXXX", myConnection)

myCommand.Comma ndType = CommandType.Sto redProcedure

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

myCommand.Param eters.Add(objPa ra1)

objPara1.Direct ion = ParameterDirect ion.Input

objPara1.Value = MsgId

' Open the connection.

myConnection.Op en()

objReader = myCommand.Execu teReader()

MsgFull.DataSou rce = objReader

MsgFull.DataBin d()

objReader.Close ()

objReader = Nothing

myConnection.Cl ose()

myConnection = Nothing
--
Kind regards

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

Nov 18 '05 #2
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(By Val fGroupId As Integer, ByVal fPageSize As
Integer) As Integer

Dim ReturnInt As Integer

Dim strConnection As String =
System.Configur ation.Configura tionSettings.Ap pSettings("strC onnect")

Dim myConnection As SqlConnection = New SqlConnection(s trConnection)

Dim myCommand As New SqlCommand("MyP roc_TotalPages" , myConnection)

myCommand.Comma ndType = CommandType.Sto redProcedure

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

myCommand.Param eters.Add(objPa ra1)

objPara1.Direct ion = ParameterDirect ion.Input

objPara1.Value = fGroupId

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

myCommand.Param eters.Add(objPa ra2)

objPara2.Direct ion = ParameterDirect ion.Input

objPara2.Value = fPageSize

' for output parameters.

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

myCommand.Param eters.Add(objOu tputPara)

objOutputPara.D irection = ParameterDirect ion.Output

' Open the connection.

myConnection.Op en()

myCommand.Execu teReader()

ReturnInt = objOutputPara.V alue

Return ReturnInt

myConnection.Cl ose()

myConnection = Nothing

End Function
--
Kind regards

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

"Marina" <so*****@nospam .com> wrote in message
news:e6******** ******@TK2MSFTN GP10.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.

Nov 18 '05 #3
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:uo******** ******@tk2msftn gp13.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(By Val fGroupId As Integer, ByVal fPageSize As Integer) As Integer

Dim ReturnInt As Integer

Dim strConnection As String =
System.Configur ation.Configura tionSettings.Ap pSettings("strC onnect")

Dim myConnection As SqlConnection = New SqlConnection(s trConnection)

Dim myCommand As New SqlCommand("MyP roc_TotalPages" , myConnection)

myCommand.Comma ndType = CommandType.Sto redProcedure

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

myCommand.Param eters.Add(objPa ra1)

objPara1.Direct ion = ParameterDirect ion.Input

objPara1.Value = fGroupId

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

myCommand.Param eters.Add(objPa ra2)

objPara2.Direct ion = ParameterDirect ion.Input

objPara2.Value = fPageSize

' for output parameters.

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

myCommand.Param eters.Add(objOu tputPara)

objOutputPara.D irection = ParameterDirect ion.Output

' Open the connection.

myConnection.Op en()

myCommand.Execu teReader()

ReturnInt = objOutputPara.V alue

Return ReturnInt

myConnection.Cl ose()

myConnection = Nothing

End Function
--
Kind regards

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

"Marina" <so*****@nospam .com> wrote in message
news:e6******** ******@TK2MSFTN GP10.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.


Nov 18 '05 #4
Thanks for your quick reply, will try it..
--
Kind regards

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

"Marina" <so*****@nospam .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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.

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1767
by: Silvia | last post by:
I have a application web and when execute this for a long time generated this error: Server Error in '/RAIMServer' Application. ----------------------------------------------------------- --------------------- Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all...
3
11086
by: Kamalanathan T. | last post by:
Hi, We have developed an Web application in ASP.NET with C# and we r using SQL Server 2000. We get the Timeout expired error, when more than 300 concurrent users hit the site. I hagone thru the code, to check whether all the Connections are closed. everything is perfect, and infact the connections are closed in the finally block.
4
4353
by: Nevyn Twyll | last post by:
I've been working on an asp.net application and everything's been great. But suddenly, whether I'm tyring to use a database on my own machine, or on my server, I'm getting a timeout when trying to open a database connection. The error seems to happen regardless of what ASP.NET app I'm working with/trying to debug. It will open a few...
3
452
by: DougS | last post by:
We have an ASP.Net (framework 1.1) app that does a lot of database reads and updates. The app has a dozen pages and we're about 90% done and all of a sudden I'm getting this error: 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...
1
1746
by: UJ | last post by:
We have recently started getting the following error message: 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 is on a connection.open command. Our ISP is providing the web machine and has many...
1
11045
by: Jake K | last post by:
I have a system timer that elapses every 10 seconds and must execute every ten seconds. Basically every 10 seconds I need to insert into a table. The following code, however, causes a "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...
1
5982
by: jobs | last post by:
Re: Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached. New webservers. win2003. IIS6. asp.net 2.0/ sql server 2005 and Oracle 9i through a 64 bit Oracle client. Everything working fine until this. I started getting these errors as the new website activity started to heat up. Timeout...
7
2747
by: =?Utf-8?B?Sm9obiBTdGFnZ3M=?= | last post by:
Hello, Please read this all before giving an answer :) I'm doing some troubleshooting on a web application that my company wrote. It's written in asp.net 1.1. The error that the Event viewer gives is: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled...
2
12605
by: anumsajeel | last post by:
Hi, Error Message:- error connecting: 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. Target Site:- MySql.Data.MySqlClient.Driver GetConnection() Error Source:- MySql.Data
0
7361
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7601
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7763
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7701
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5289
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4908
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
654
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.