I usually refer to this as the bankrobbers 3G rule:
Go in,
Get what you want and
Get out....
The idea here is that you open the connection as late as possible, use it for the shortest possible time, and close it as soon as you're done.
There's no point in opening a connection if you're not going to use it. Connections are a scarce resource, and should be treated as such. Since connection pooling takes away much of the performance hit of creating a connection, you'll find generally that opening and closing it more than once on a single page doesn't hinder performance. Obviously, if you perform two or more data operations in a single call, you might as well let them share the connection.
From an OO and maintenance point of view, yo could let each function create its own connection object, open it and close it when it's done. If you want to pass DataReaders back from methods, you can use CommandBehavior.CloseConnection to indicate the connection must be closed when the reader is done reading.
For more info, take a look here:
http://msdn2.microsoft.com/en-us/library/ms998569.aspx
It's a bit old, but it still applies....
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of
ASP.NET 2.0 Instant Results and
Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.