I usually write my datareader code like this:
try
{
dr = cmd.ExecuteReader(CommandBehavior.SingleResult);
while (dr.Read())
{
//Do stuff
}
}
finally
{
if (dr != null) { dr.Close(); }
}
Is it safe to replace the try/finally w/ just a using block around the DataReader's creation? The reason I wonder is because in all the MS examples I've seen they use a using for the connection but always explictly call Close() on the DataReader.
Heres's an example: http://msdn.microsoft.com/en-us/library/haa3afyz(VS.100).aspx