Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 18th, 2008, 09:39 AM
Friend of Wrox
Points: 2,876, Level: 22
Points: 2,876, Level: 22 Points: 2,876, Level: 22 Points: 2,876, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default Find Open DB Connections?

I am randomly getting this error every few days:

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

I don't wish to increase pool size or turning off pooling.

I just want to figure out which connection(s) are being left open. There is a lot of code to be checked, so randomly searching for this problem is unlikely to find the problem, and a trace could potentially turn up hundreds of DB calls that would be as painful to search as the code itself. Are there any tools or techniques that can help me find where in my code connections are being left open.
  #2 (permalink)  
Old April 20th, 2008, 09:40 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to humour
Default


I realize this won't help a lot now but I have adopted a technique wherein all DB interactions by my coding practice occur via Class Functions. Within the Function I allways dispose of my connection objects. Disposed connection objects should immediately release resources to the connection-pool.

I have tried asking on other forums if this is a good technique or a bad technique.... (perhaps it has a cost penalty in performance - I really don't know).

In any case I have provided an example below.

Dim ss As String
        ss = Me.GetConnectionString(connectname)
        Dim sqlconn As New SqlConnection(GetConnectionString(connectname))
        Dim SQLComm As New SqlCommand(sql, sqlconn)
        sqlconn.Open()
        SQLComm.ExecuteNonQuery()
        sqlconn.Close()
        sqlconn.Dispose()
        SQLComm.Dispose()
  #3 (permalink)  
Old April 23rd, 2008, 10:21 AM
Friend of Wrox
Points: 2,876, Level: 22
Points: 2,876, Level: 22 Points: 2,876, Level: 22 Points: 2,876, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

Thanks for the advice, but I am trying to do the same thing.

I will repost the question now lest anybody think I got a useful response.
  #4 (permalink)  
Old April 23rd, 2008, 10:35 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there... the only real advice, is to control every db open and close it when you don't needed anymore..

Also, if you have hundreds of DB open, that is not a good quality code, maybe you have to refactor it??

Humour idea is not bad, at least you will trace your code better.

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
  #5 (permalink)  
Old April 23rd, 2008, 11:27 AM
Friend of Wrox
Points: 2,876, Level: 22
Points: 2,876, Level: 22 Points: 2,876, Level: 22 Points: 2,876, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

You understanding of the problem is at best incomplete and, in any case, I do not have the luxury of rewriting this code. I simply asked for a technique for identifying where one leak is occuring. If you can answer that question, I would be most interested in your response. But advice to rewrite a 100K line system to prevent one open DB connection is not helpful.
  #6 (permalink)  
Old April 23rd, 2008, 11:51 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Without going back and tracing your code (and I understand that it would be a rather large undertaking for 100K lines of code) you are probably going to have to resort to doing this from the SQL side.

In SQL Server 2K you have the system proc sp_who 'username' which will give you information about the user, the last executed command etc. (Most of this information can also be seen through Enterprise Manager) Pay close attention to the last command the user executed as this will at least "get you in the ballpark" of where the connection leak may be coming from.

Further, if you are using Sql Server 2K5 you can also use sp_who2 which contains some more detailed information about the connection.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #7 (permalink)  
Old April 23rd, 2008, 12:29 PM
Friend of Wrox
Points: 2,876, Level: 22
Points: 2,876, Level: 22 Points: 2,876, Level: 22 Points: 2,876, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

Thanks, Doug!

Looking at it right now, all of the SPIDS are SLEEPING and there appear to be fewer SPIDS than pooled connections I allowed for in the connection string. Is there some way to identify opened connections or is this only useful once the error manifests?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find open DB Connection again Ron Howerton ASP.NET 2.0 Professional 0 April 23rd, 2008 10:29 AM
asp can't open db when db open by other program datuk Classic ASP Professional 3 June 13th, 2006 06:10 PM
Detecting Open Database Connections? Ron Howerton SQL Server ASP 1 July 14th, 2005 02:26 PM
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
Closing db connections - when/how? SoC Classic ASP Basics 11 November 23rd, 2004 05:47 PM



All times are GMT -4. The time now is 09:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.