Hi guys,
In C# when i use the using statement. in case of try catch do i have to close the connection in case of any error.
try
{
using (connect=connecttodabase())
{
SqlParameter demo_ID = new SqlParameter();
SqlCommand command = new SqlCommand("Demo", connect);
command.Parameters.Add(demo_ID);
int rowsAffected = command.ExecuteNonQuery();
return demo_ID.Value.ToString();
}
}
catch (Exception)
{
throw;
}
Do i have to close the connection using finally.