Beware of data readers; they have a nasty habit of causing numerous
orphaned connections on database servers because of the way they carry an
open connection with them. You must call ExecuteReader with the
CommandBehavior.CloseConnection parameter to ensure that, once the
DataReader is closed, the connection it uses is closed. AND you must
remember to specifically call the Close method on the DataReader.
I don't really like the idea of a "connection factory" method that feeds
them out to various routines. I think that connections should be opened and
closed within the routines that access the data.
If you're careful, returning DataReaders will work but remember the caveat
that they carry with them an open connection, even if you called Close on
the connection you used to open them.
Steven Bras, MCSD
Microsoft Developer Support/Data Access Technologies
This posting is provided "AS IS" with no warranties, and confers no rights.
Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-026?* If not Microsoft strongly advises you to
review the information at the following link regarding Microsoft Security
Bulletin MS03-026
http://www.microsoft.com/security/se...s/ms03-026.asp and/or to
visit Windows Update at
http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026.