Hi
I have some code in C# for accessing a database. For example:
using (SqlConnection conn = GetConnection() )
{
using (SqlCommand command = new SqlCommand( ...
{
...
}
}
(The function GetConnection just delivers the appropriate connection object,
and of course there is a lot of code snipped).
My question concerns the "using" statement. I just want to be sure that my
understanding is correct: it is not necessary for me to explicitly close
these database resources because the using statement ensures that these
objects have a Dispose function which is called, and these take care of
cleaning up? (Even if an exception is thrown?)
Thanks,
Peter