Link to home
Start Free TrialLog in
Avatar of niceguy971
niceguy971

asked on

C# - the method to get a number of open Sql connections

What would be the best way to create a method which returns the number of open Sql connections?  Let say I'm debugging my code (or even at some points in the code) - i would like to check at some point and make sure that all connections where closed.

SqlConnection connection = new SqlConnection( connectionString)

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of niceguy971
niceguy971

ASKER

It's a good approach..but it does NOT answer my original question. Let say... I would like to have a method which returns the number of open Sql connections. How to create such method? It's also very interesting from the theoretical standpoint.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Really intresting!! But using the 'using' keyword requires no need to verify this extra work. That is the best practice. No connection or memory leak will happen. We have used in our real project and found good improvement in performance as well.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks