Doris Manning
mikedorism at verizon.net
Wed Feb 16 07:06:33 CST 2011
I usually close in the following order: reader, connection, and then command. Doris Manning -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Monday, February 14, 2011 8:24 PM To: VBA Subject: [dba-VB] c# - close in any particular order? I have a connection, a command object and a data reader (all SQL objects). Do I need to close them in any specific order? ATM the code does this: SqlDataReader dr; SqlConnection cnn = new SqlConnection(clsGlobals.myConnection); cnn.Open(); SqlCommand cmd = new SqlCommand(SQL, cnn); dr = cmd.ExecuteReader(); while (dr.Read()) { } cnn.Dispose(); cnn.Close(); cmd.Dispose(); dr.Dispose(); dr.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