Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 [Unclosed connection] [Log per connections]

Author  Topic 

clement_911
Starting Member

2 Posts

Posted - 2008-07-03 : 00:44:20
Dear Sql Server 2005 experts.

I noticed that some db connections are not closed and would like to find which method(s) in my code is responsible.
By launching the sql server profiler, I can see that there are existing connections. In order to back trace the faulty method I need to know the different commands that have been executed with that connection.
Hence my questions : Is it possible to see the history of commands for an existing connection ?

Thank you.

Clement

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2008-07-03 : 09:23:35
It's not necessary to profile your code to determine where this is happening. Simply review your code and look for any code that opens a connection and does not (a) close the connection and (b) dispose of the connection. We recently encountered this in our system and I ended up directing our development staff to implement connection pooling as well as invoking the .Dispose() method on all connections when they close it (we develop in .NET using C#).
Go to Top of Page

maninder
Posting Yak Master

100 Posts

Posted - 2008-07-03 : 10:18:13
tfountain is right? Adding to it, there is not such method to go back into time to check for connection and Queries, unless you maintain a deliberate history in Tables or else where.
There is a Default SQL Trace that gets written down in the LOG Folder in SQL Server Path. check that and see if you can figure something from that.. But again that only maintained for a day or Two by SQL Server Engine Itself.

Maninder
Database Painter.. Leaving strokes, that amaze! and inreturn, put value to your Work. I am a Database [Architect / Administrator]
Go to Top of Page

clement_911
Starting Member

2 Posts

Posted - 2008-07-03 : 19:57:05
Thanks guys,
i am a bit disappointed though, what if you have millions of line of code !
Go to Top of Page

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2008-07-07 : 13:53:43
quote:
Originally posted by clement_911

Thanks guys,
i am a bit disappointed though, what if you have millions of line of code !



We do have millions of lines of code. The effort to of doing a profile versus a search in any modern IDE definitely weighs strongly on just doing a search and replace.
Go to Top of Page
   

- Advertisement -