I've doubt what is the significant difference by applying the "Using" statement in same code block with different way , it would be good to know practice the best way for me sameple 1 code block
using (SqlConnection SqlConnection = new SqlConnection(dbConnectionString))
{
SqlConnection.Open();
using (var command = new SqlCommand(store_procName, SqlConnection))
{
command.Parameters.Add(Constants.PARAM_Value, SqlDbType.VarChar).Value = Id;
command.CommandType = CommandType.StoredProcedure;
using (var adp = new SqlDataAdapter(command))
{
adp.Fill(dtValid);
}
}
}
return dtValid;
sample code block 2
using (SqlConnection SqlConnection = new SqlConnection(dbConnectionString))
{
SqlConnection.Open();
SqlCommand command = new SqlCommand(store_procName, SqlConnection);
command.Parameters.Add(Constants.PARAM_Value, SqlDbType.VarChar).Value = Id;
command.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = new SqlDataAdapter(command);
adp.Fill(dtValid);
}
return dtValid;