Stefan Steinegger
Stefan Steinegger

Reputation: 64628

SqlConnection.ClearAllPools, what is cleared?

I have an application which uses SqlConnection.ClearAllPools to close all connections before dropping a database.

There is a case where a connection is still there. This connection had been created in another application domain.

So I wonder which connections are closed by SqlConnection.ClearAllPools?

Upvotes: 10

Views: 7662

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

It closes all the connections opened by the calling process only. It empties all the connection pools which are bound to the process. Quote:

Connection pool and connection string go hand in hand. Every connection pool is associated with a distinct connection string and that too, it is specific to the application. In turn, what it means is – a separate connection pool is maintained for every distinct process, app domain and connection string.

Upvotes: 10

Related Questions