473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Connection pooling problem

PH
Hi;

I got an application written in ASP.NET (VB.NET and C#) that uses
connection pooling.
The Max connections defined in the connection command are 50, and there
are no more than 3 or 4 user using the application (intranet).
I very carefully open the connections in the LOAD event and close them
in the PreRender event.
Usually I got only one connection opened per FORM.

I also got a Class called ExecuteSQL(). This class has a public member
called Connection of type SQLConnection.
If this parameter (connection) is supplied I open the connection as I
explained before, in the LOAD event, I call ExecuteSQL, and close the
connection on PreRender.

If i do not supply this parameter, ExecuteSQL() uses an internal
connection, and close I close it calling ExecuteSQL.Dispose().

Again I'm very careful opening and closing connections.

Anyway, I got this error when doing something in the database saying
that a connection cannot be retrieved from the connection pool, probably
because all of them are in use.
Remember that I got at most 4 users and 50 predefined connections in the
pool.

What's happening?
Some help? ;-)

Thanks


Mar 18 '06 #1
2 1588
If you are getting this exception, you need to revisit your code since
somewhere you have connections that - even though you "Say" they are, are NOT
Being closed.

The best practices pattern for ADO.NET is to open a connection IMMEDIATELY
BEFORE doing the Sql call, and close it immediately thereafter.

This allows your connection to return to the pool. Subsequent requests for
this connection using the same connection string don't incur the overhead of
instantiating a connection, since it comes directly out of the pool.

The default pool has 100 connections. In most cases, there should be no need
to change this.

Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"PH" wrote:
Hi;

I got an application written in ASP.NET (VB.NET and C#) that uses
connection pooling.
The Max connections defined in the connection command are 50, and there
are no more than 3 or 4 user using the application (intranet).
I very carefully open the connections in the LOAD event and close them
in the PreRender event.
Usually I got only one connection opened per FORM.

I also got a Class called ExecuteSQL(). This class has a public member
called Connection of type SQLConnection.
If this parameter (connection) is supplied I open the connection as I
explained before, in the LOAD event, I call ExecuteSQL, and close the
connection on PreRender.

If i do not supply this parameter, ExecuteSQL() uses an internal
connection, and close I close it calling ExecuteSQL.Dispose().

Again I'm very careful opening and closing connections.

Anyway, I got this error when doing something in the database saying
that a connection cannot be retrieved from the connection pool, probably
because all of them are in use.
Remember that I got at most 4 users and 50 predefined connections in the
pool.

What's happening?
Some help? ;-)

Thanks

Mar 18 '06 #2
Hi PH,
I don't know you are coding but one good way to make sure you never forget
to close a connection is to use the "using" statement. This guarantees that
the Dispose method always gets called which internally calls close and makes
sure the underlying connection gets returned to the connection pool.

For example:

using(SqlConnection connection = new SqlConnection())
{
// do DB open and execute tasks
}

// Here the connection has been closed.

The using statement will call Dispose even if an exception is thrown inside
the code, since behind the scenes it makes sure the call to Dispose is in a
finally block.

Mark Dawson
http://www.markdawson.org
"PH" wrote:
Hi;

I got an application written in ASP.NET (VB.NET and C#) that uses
connection pooling.
The Max connections defined in the connection command are 50, and there
are no more than 3 or 4 user using the application (intranet).
I very carefully open the connections in the LOAD event and close them
in the PreRender event.
Usually I got only one connection opened per FORM.

I also got a Class called ExecuteSQL(). This class has a public member
called Connection of type SQLConnection.
If this parameter (connection) is supplied I open the connection as I
explained before, in the LOAD event, I call ExecuteSQL, and close the
connection on PreRender.

If i do not supply this parameter, ExecuteSQL() uses an internal
connection, and close I close it calling ExecuteSQL.Dispose().

Again I'm very careful opening and closing connections.

Anyway, I got this error when doing something in the database saying
that a connection cannot be retrieved from the connection pool, probably
because all of them are in use.
Remember that I got at most 4 users and 50 predefined connections in the
pool.

What's happening?
Some help? ;-)

Thanks

Mar 19 '06 #3

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

Similar topics

0
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem...
5
by: John | last post by:
Does COM.ibm.db2.jdbc.DB2DataSource, (which supports connection pooling) need to be run within a J2EE container environment before the connection pooling facility is actually available to a user? ...
1
by: Mark | last post by:
I know that DB2 LUW version 8 has "connection pooling" that provides a connection concentrator (limits the number of simultaneous connections that can occur). But does it really provide connection...
0
by: iac | last post by:
I am trying to write a Windows Service which does the following whenever the SQLServer it is connected to suddenly goes down: It periodically checks to see if it can connect to the database, if...
1
by: Lenny Shprekher | last post by:
Hi, I am getting issues that Oracle collecting opened sessions (connections) from my webservice using regular System.Data.OleDb.OleDbConnection object. I am guessing that this is connection...
1
by: PH | last post by:
Hi; I got an application written in ASP.NET (VB.NET and C#) that uses connection pooling. The Max connections defined in the connection command are 50, and there are no more than 3 or 4 user...
2
by: Dan D. | last post by:
Let me say first that I don't know much about .NET. We inherited an app from a group of developers and we have a second group of contractors working on the app. The first group set min=100 in the...
3
by: howachen | last post by:
Hi, Is that when using pconnect to mysql, it is already mean connection pooling? thanks.
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.