Search code examples
c#sqlconnectionmonitor

how to monitor SQL client connection number in C#


In C# client side, we can open SQL connections based on connection string. Connection pool is used to improve the client performance.

We want to monitor how many connections are active and how many are free for use, which is very important to client side health check. Unfortunately, I didn't find any way to get this kind of information. Can any one tell me? Or I have to implement it by myself?


Solution

  • You need to have a wrapper class with count variable to monitor count of connection, on connection.Open() increment by 1 and on connetion.Close() decrement by 1.