patd1
asked on
SqlConnection
Pls see code attached.
Do I need to write cnn.Close() and cnn.Dispose() statements in that code or the statement
Thanks.
Do I need to write cnn.Close() and cnn.Dispose() statements in that code or the statement
using (var cnn = new SqlConnection(MyConnection)){}
takes care of it automatically?Thanks.
using (var cnn = new SqlConnection(MyConnection))
{
using (var cmd = new SqlCommand("[mySchema].[UpdateComments]", cnn))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@comment", comment);
cnn.Open();
cmd.ExecuteNonQuery();
}
cnn.Close();
cnn.Dispose();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.