472,794 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 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 2271
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.