Bobby Heid
bheid at sc.rr.com
Wed Jul 28 11:08:16 CDT 2010
I think they are talking about calling close in an overridden Finalize method on a class. That would only be if you implement your own dispose/finalize methods in a class. You do want to close the reader and all if you are just using ado.net to connect to and read from a SQL/OLEdb connection. Bobby -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Sunday, July 25, 2010 3:30 PM To: VBA Subject: [dba-VB] C# - what does this mean From: http://msdn.microsoft.com/en-us/library/haa3afyz%28VS.71%29.aspx Closing the DataReader You should always call the Close method when you have finished using the DataReader object. If your Command contains output parameters or return values, they will not be available until the DataReader is closed. Note that while a DataReader is open, the Connection is in use exclusively by that DataReader. You will not be able to execute any commands for the Connection, including creating another DataReader, until the original DataReader is closed. Note Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. For more information, see Programming for Garbage Collection. NOTICE the Note above. Why would you NOT call close at the very least. I understand Dispose - that is the garbage collector's job to do that when it decides it needs to but close? -- John W. Colby www.ColbyConsulting.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com