We use an automated testing tool and I restore the
database before each testcase that modifies the database.
Therefore I need to kill all open connections to the SQL-
Server database (using the T-SQL KILL statement).
Unfortunately, the SQL connection pool isn't notified that
the connection is cancelled. So when a new connection is
opened (that is retrieved from the pool) a 'General
Network Error' occurs.

I have solved this to disable connection pooling while
testing (setting "pooling='false'" in the connection
string). I would rather flush the connection pool, but I
cannot find a way to do this from a .NET environment.

Does anyone know how to manage the connection pool from
within a .NET application?

Re: Clearing SQL-Server connection pool by Miha

Miha
Thu Dec 18 13:31:38 CST 2003

Hi Ramon,

You are correct that pool isn't notified.
The way the ado.net works is that: when it tries to open a (faulty or
broken) connection it will remove it from the pool.
So, you should catch that kind of exception and retry the connection.Open.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Ramon de Klein" <Ramon.de.Klein@ict.nl> wrote in message
news:021a01c3c597$87acfae0$a301280a@phx.gbl...
> We use an automated testing tool and I restore the
> database before each testcase that modifies the database.
> Therefore I need to kill all open connections to the SQL-
> Server database (using the T-SQL KILL statement).
> Unfortunately, the SQL connection pool isn't notified that
> the connection is cancelled. So when a new connection is
> opened (that is retrieved from the pool) a 'General
> Network Error' occurs.
>
> I have solved this to disable connection pooling while
> testing (setting "pooling='false'" in the connection
> string). I would rather flush the connection pool, but I
> cannot find a way to do this from a .NET environment.
>
> Does anyone know how to manage the connection pool from
> within a .NET application?