closing open connections and other resources

  • Thread starter Thread starter csharpbeginner
  • Start date Start date
C

csharpbeginner

My requirement is a certain database connection should be
closed only when the object is unloaded from memory. Is
the class destructor a good place to close open database
connections? Thanks in advance for your reply.
 
There are a lot of good reasons not to do this. Leaving connections open
indefinitely has many potential problems, connection pooling being the most
noticeable.
However, you could implement IDisposable and take care of it there.
 
Back
Top