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 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.
.