SQLConnection pool size and active connection count in C#

phoad picture phoad · Aug 11, 2014 · Viewed 9.8k times · Source

In C# it is possible to enable/disable Connection Pooling by using "Pooling=True" and "Max Pool Size=XY" in connection string.

Like: What is maximum allowable value of "Max Pool Size" in sql connection string

Is it possible to ask how many connections to SQL server is active and what is the current pool size programmatically?

Answer

Vlad Rudenko picture Vlad Rudenko · Jun 6, 2015

You can use NumberOfActiveConnections or NumberOfPooledConnections ADO.NET performance counter:

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/performance-counters