By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,344 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,344 IT Pros & Developers. It's quick & easy.

connection pooling error

P: n/a
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
Share this Question
Share on Google+
6 Replies

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.