closing open connections and other resources

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.
 
W

William Ryan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top