Opening and closing connections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If you have ASP.Net pages that contain multiple user controls and reference
multiple classes, is it better to:
1. Open a single connection and pass it around to all objects that need to
access data, or
2. Open a connection within each individual control, page, or class for
internal usage, or
3. Open a connection each time data needs to be accessed?

If 1 or 2, how do you make sure the connection gets closed? Thanks!
 
Your last question is one of the problems I was going to point out before I
finished reading the thread. I usually open and close the connection
immediately around where I need the data. That way I know the resources are
released.
 
Back
Top