473,404 Members | 2,174 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,404 software developers and data experts.

connection pooling error

I've created a data access layer for a .NET web
application. I'm using C# and framework 1.1. I'm getting
an error from time to time when I close a connection
saying: System.InvalidOperationException: A connection
pooling error has occurred.

It doesn't happen each time, the exception is thrown
randomly. The big problem is that the connection is left
active in the pool. After a short period of time, the
pool is filled up and people can't access the site.

Has anyone ever run into this before? Any ideas on how I
might correct the problem? Any help is greatly
appreciated.

Chris Szabo.
Nov 17 '05 #1
6 2321
Can post some code? How are you accessing and releasing your connection??

"Chris Szabo" <ch****@artifact-entertainment.com> wrote in message
news:26****************************@phx.gbl...
I've created a data access layer for a .NET web
application. I'm using C# and framework 1.1. I'm getting
an error from time to time when I close a connection
saying: System.InvalidOperationException: A connection
pooling error has occurred.

It doesn't happen each time, the exception is thrown
randomly. The big problem is that the connection is left
active in the pool. After a short period of time, the
pool is filled up and people can't access the site.

Has anyone ever run into this before? Any ideas on how I
might correct the problem? Any help is greatly
appreciated.

Chris Szabo.

Nov 17 '05 #2
Sure... here's some code.

private void killConn()
{
if (cmdSQL.Connection != null)
{
try
{
cmdSQL.Connection.Close();
cmdSQL.Connection.Dispose();
}
catch ( Exception e )
{
l.writeException ( e );
}
}
}

public SqlCommand cmdSQL
{
get
{
if ( _cmdSQL == null )
_cmdSQL = new SqlCommand ( );

if ( _cmdSQL.Connection == null )
_cmdSQL.Connection = new SqlConnection(connString);

if ( _cmdSQL.Connection.ConnectionString == null ||
_cmdSQL.Connection.ConnectionString==String.Empty )
_cmdSQL.Connection.ConnectionString = connString;

if ( _cmdSQL.Connection.State ==
ConnectionState.Closed )
{
try
{
_cmdSQL.Connection.Open ( );
}
catch ( Exception e )
{
l.writeException ( e );
}
}
return _cmdSQL;
}
}
-----Original Message-----
Can post some code? How are you accessing and releasing your connection??
"Chris Szabo" <ch****@artifact-entertainment.com> wrote in messagenews:26****************************@phx.gbl...
I've created a data access layer for a .NET web
application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection
saying: System.InvalidOperationException: A connection
pooling error has occurred.

It doesn't happen each time, the exception is thrown
randomly. The big problem is that the connection is left active in the pool. After a short period of time, the
pool is filled up and people can't access the site.

Has anyone ever run into this before? Any ideas on how I might correct the problem? Any help is greatly
appreciated.

Chris Szabo.

.

Nov 17 '05 #3
Hmm... some things to consider..

You could use the "Singleton" pattern and have a static connection that gets
reused because really - you can have multiple operations happen over one
connection. if you do this, everytime before you make a SQL call, make sure
the connection is open, if it's not - then open it.

but the first thing that came to mind is that you are trying to manually
..Dispose() of the object, and for connection pooling - it seems to be all or
nothing. Either you control all connections opening or closing - or you let
cp handle it.. So I'd say get comment out the .Dispose() and see if this
still happens..

And if the database is SQL2K - you can run the SQL Profiler and watch the
connections and see what happens every time there is a new connection..

hth

"Chris Szabo" <ch****@artifact-entertainment.com> wrote in message
news:01****************************@phx.gbl...
Sure... here's some code.

private void killConn()
{
if (cmdSQL.Connection != null)
{
try
{
cmdSQL.Connection.Close();
cmdSQL.Connection.Dispose();
}
catch ( Exception e )
{
l.writeException ( e );
}
}
}

public SqlCommand cmdSQL
{
get
{
if ( _cmdSQL == null )
_cmdSQL = new SqlCommand ( );

if ( _cmdSQL.Connection == null )
_cmdSQL.Connection = new SqlConnection(connString);

if ( _cmdSQL.Connection.ConnectionString == null ||
_cmdSQL.Connection.ConnectionString==String.Empty )
_cmdSQL.Connection.ConnectionString = connString;

if ( _cmdSQL.Connection.State ==
ConnectionState.Closed )
{
try
{
_cmdSQL.Connection.Open ( );
}
catch ( Exception e )
{
l.writeException ( e );
}
}
return _cmdSQL;
}
}
-----Original Message-----
Can post some code? How are you accessing and releasing

your connection??

"Chris Szabo" <ch****@artifact-entertainment.com> wrote

in message
news:26****************************@phx.gbl...
I've created a data access layer for a .NET web
application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection
saying: System.InvalidOperationException: A connection
pooling error has occurred.

It doesn't happen each time, the exception is thrown
randomly. The big problem is that the connection is left active in the pool. After a short period of time, the
pool is filled up and people can't access the site.

Has anyone ever run into this before? Any ideas on how I might correct the problem? Any help is greatly
appreciated.

Chris Szabo.

.

Nov 17 '05 #4
Okay, I'll give that a try. Can you fill me in on
the "Singleton" pattern? I've actually been trying to
accomplish this since we expect massive amounts of traffic
on the site. I haven't been able to come up with anything.

Thanks,
Chris Szabo.
-----Original Message-----
Hmm... some things to consider..

You could use the "Singleton" pattern and have a static connection that getsreused because really - you can have multiple operations happen over oneconnection. if you do this, everytime before you make a SQL call, make surethe connection is open, if it's not - then open it.

but the first thing that came to mind is that you are trying to manually..Dispose() of the object, and for connection pooling - it seems to be all ornothing. Either you control all connections opening or closing - or you letcp handle it.. So I'd say get comment out the .Dispose() and see if thisstill happens..

And if the database is SQL2K - you can run the SQL Profiler and watch theconnections and see what happens every time there is a new connection..
hth

"Chris Szabo" <ch****@artifact-entertainment.com> wrote in messagenews:01****************************@phx.gbl...
Sure... here's some code.

private void killConn()
{
if (cmdSQL.Connection != null)
{
try
{
cmdSQL.Connection.Close();
cmdSQL.Connection.Dispose();
}
catch ( Exception e )
{
l.writeException ( e );
}
}
}

public SqlCommand cmdSQL
{
get
{
if ( _cmdSQL == null )
_cmdSQL = new SqlCommand ( );

if ( _cmdSQL.Connection == null )
_cmdSQL.Connection = new SqlConnection(connString);

if ( _cmdSQL.Connection.ConnectionString == null || _cmdSQL.Connection.ConnectionString==String.Empty ) _cmdSQL.Connection.ConnectionString = connString;

if ( _cmdSQL.Connection.State ==
ConnectionState.Closed ) {
try
{
_cmdSQL.Connection.Open ( );
}
catch ( Exception e )
{
l.writeException ( e );
}
}
return _cmdSQL;
}
}
>-----Original Message-----
>Can post some code? How are you accessing and releasing

your connection??
>
>"Chris Szabo" <ch****@artifact-entertainment.com> wrote

in message
>news:26****************************@phx.gbl...
>> I've created a data access layer for a .NET web
>> application. I'm using C# and framework 1.1. I'm

getting
>> an error from time to time when I close a connection
>> saying: System.InvalidOperationException: A connection >> pooling error has occurred.
>>
>> It doesn't happen each time, the exception is thrown
>> randomly. The big problem is that the connection is

left
>> active in the pool. After a short period of time, the >> pool is filled up and people can't access the site.
>>
>> Has anyone ever run into this before? Any ideas on
how I
>> might correct the problem? Any help is greatly
>> appreciated.
>>
>> Chris Szabo.
>
>
>.
>

.

Nov 17 '05 #5
Kill cmdSQL.Connection.Dispose(); GC issue, with Dispose() left alive
until blah blah blah maybe?
"Chris Szabo" <ch****@artifact-entertainment.com> wrote in message
news:01****************************@phx.gbl...
Sure... here's some code.

private void killConn()
{
if (cmdSQL.Connection != null)
{
try
{
cmdSQL.Connection.Close();
cmdSQL.Connection.Dispose();
}
catch ( Exception e )
{
l.writeException ( e );
}
}
}

public SqlCommand cmdSQL
{
get
{
if ( _cmdSQL == null )
_cmdSQL = new SqlCommand ( );

if ( _cmdSQL.Connection == null )
_cmdSQL.Connection = new SqlConnection(connString);

if ( _cmdSQL.Connection.ConnectionString == null ||
_cmdSQL.Connection.ConnectionString==String.Empty )
_cmdSQL.Connection.ConnectionString = connString;

if ( _cmdSQL.Connection.State ==
ConnectionState.Closed )
{
try
{
_cmdSQL.Connection.Open ( );
}
catch ( Exception e )
{
l.writeException ( e );
}
}
return _cmdSQL;
}
}
-----Original Message-----
Can post some code? How are you accessing and releasing

your connection??

"Chris Szabo" <ch****@artifact-entertainment.com> wrote

in message
news:26****************************@phx.gbl...
I've created a data access layer for a .NET web
application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection
saying: System.InvalidOperationException: A connection
pooling error has occurred.

It doesn't happen each time, the exception is thrown
randomly. The big problem is that the connection is left active in the pool. After a short period of time, the
pool is filled up and people can't access the site.

Has anyone ever run into this before? Any ideas on how I might correct the problem? Any help is greatly
appreciated.

Chris Szabo.

.

Nov 17 '05 #6
I've modified the code as follows and I'm still getting
the same error. I can actually step through it, verify
that _cmdSQL is not null, .Connection is not null, and the
state is open. When I reach the try catch block an
exception is still thrown, A connection pooling error has
occurred.

private void killConn()
{
if ( _cmdSQL != null )
{
if ( _cmdSQL.Connection != null )
{
if ( _cmdSQL.Connection.State !=
ConnectionState.Closed )
{
try
{
_cmdSQL.Connection.Close();
}
catch ( Exception e )
{
l.writeException ( e );
}
}
}
}
}

Any more ideas...?
-----Original Message-----
Okay, I'll give that a try. Can you fill me in on
the "Singleton" pattern? I've actually been trying to
accomplish this since we expect massive amounts of trafficon the site. I haven't been able to come up with anything.
Thanks,
Chris Szabo.
-----Original Message-----
Hmm... some things to consider..

You could use the "Singleton" pattern and have a static

connection that gets
reused because really - you can have multiple operations

happen over one
connection. if you do this, everytime before you make a

SQL call, make sure
the connection is open, if it's not - then open it.

but the first thing that came to mind is that you are

trying to manually
..Dispose() of the object, and for connection pooling -

it seems to be all or
nothing. Either you control all connections opening or

closing - or you let
cp handle it.. So I'd say get comment out the .Dispose()

and see if this
still happens..

And if the database is SQL2K - you can run the SQL

Profiler and watch the
connections and see what happens every time there is a

new connection..

hth

"Chris Szabo" <ch****@artifact-entertainment.com> wrote

in message
news:01****************************@phx.gbl...
Sure... here's some code.

private void killConn()
{
if (cmdSQL.Connection != null)
{
try
{
cmdSQL.Connection.Close();
cmdSQL.Connection.Dispose();
}
catch ( Exception e )
{
l.writeException ( e );
}
}
}

public SqlCommand cmdSQL
{
get
{
if ( _cmdSQL == null )
_cmdSQL = new SqlCommand ( );

if ( _cmdSQL.Connection == null )
_cmdSQL.Connection = new SqlConnection(connString);

if ( _cmdSQL.Connection.ConnectionString == null||_cmdSQL.Connection.ConnectionString==String.Emp ty ) _cmdSQL.Connection.ConnectionString = connString;

if ( _cmdSQL.Connection.State ==
ConnectionState.Closed ) {
try
{
_cmdSQL.Connection.Open ( );
}
catch ( Exception e )
{
l.writeException ( e );
}
}
return _cmdSQL;
}
}

>-----Original Message-----
>Can post some code? How are you accessing and releasing your connection??
>
>"Chris Szabo" <ch****@artifact-entertainment.com> wrote in message
>news:26****************************@phx.gbl...
>> I've created a data access layer for a .NET web
>> application. I'm using C# and framework 1.1. I'm
getting
>> an error from time to time when I close a connection
>> saying: System.InvalidOperationException: Aconnection >> pooling error has occurred.
>>
>> It doesn't happen each time, the exception is thrown
>> randomly. The big problem is that the connection is
left
>> active in the pool. After a short period of time,the >> pool is filled up and people can't access the site.
>>
>> Has anyone ever run into this before? Any ideas onhow I
>> might correct the problem? Any help is greatly
>> appreciated.
>>
>> Chris Szabo.
>
>
>.
>

.

.

Nov 17 '05 #7

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

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
4
by: Mark | last post by:
OK. Here we go. I have an ASP.NET application that does many hits to a SQL Server DB on a separate server. When I first created this application (2 years ago) and was very new to ASP/ASP.NET, to...
18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
5
by: Brian Kitt | last post by:
I wanted to post this on the SQL newsgroup, but I get a 'page not found' when trying to go to that newsgroup. Since it is a C# app, I'll try it here. I have a C# web application (.NET 1.1). I...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
29
by: Bryce K. Nielsen | last post by:
Suddenly this week, I've started getting this error message: System.Data.SqlClient.SqlConnection(GetOpenConnection)ExecuteNonQuery requires an open and available Connection. The connection's...
20
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I...
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...
15
by: Sylvie | last post by:
I have a static function in a class, everytime I call this function, I am creating a SQLconnection, open it, use it, and null it, All my functions and application logic is like this, Every...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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,...
0
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...
0
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...

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.