Close connection in finalizer
In a class of my asp.net application, I open connection in constructor and I want close connection in finalizer method but .close fails. I have read this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlconnectionclassclosetopic.asp
CAUTION Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. For more information, see Programming for Garbage Collection.
How can I close this connection?
Thankssss
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

shimtannyRank #3,312 · 434 pointsPosted Feb 24, 2005, 2:45 AM EST
alainc21 pointsPosted Feb 24, 2005, 4:35 AM EST