简体   繁体   中英

list of all sqlConnection created by my .net application

I am working on net project (WCF service). Code is not so good at many places in code sql connection is not properly handled. I am using SOAP UI for tesing web API. I have created SOAP UI project. Now I would like to know list of all sql connection created by my SOAP UI test when i ran SOAP UI test project. Is there any way to get list of all connection?. Please let me know. [I just wanted to show this result to management to get code refactor approval.]

You can run this query to find the list of active sessions for each database and then get the one that you want accordingly.

select 
    db_name(dbid) as [Database Name], 
    count(dbid) as [No Of Connections],
    loginame as [Login Name]
from
    sys.sysprocesses
where 
    dbid > 0
group by 
    dbid, loginame

Its taken from the following link. Find active sessions

Some time ago I wrote a post how to collect ADO.NET traces. As far as I know these traces are the most detailed logs of ADO.NET activity in your application - just tune them to your needs. The post is available here: https://lowleveldesign.wordpress.com/2012/09/07/diagnosing-ado-net-with-etw-traces/ . If you have any problems just let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM