J
Jon Oskar
Hi all,
although I'm a seasoned .NET developer I decided to cast my wanderings
to you all...
I'm building a ASP.NET solution and was coding a function in my BL
when this question struck me:
- When using SqlConnection and SqlCommand (which are both disposable)
which is better, to use:
try
{
using( SqlConnection conn = new SqlConnection(connString) )
{
using( SqlCommand comm = new SqlCommand() )
{
//...code lies here...
}
}
}
catch
{}
- OR -
having a try-catch-finally block surrounding my code and disposing the
objects in the finally clause?? or, should I dispose the objects
explicitly at all (just null 'em) ???
your thoughts appreciated on this...
regards,
Jon Oskar
although I'm a seasoned .NET developer I decided to cast my wanderings
to you all...
I'm building a ASP.NET solution and was coding a function in my BL
when this question struck me:
- When using SqlConnection and SqlCommand (which are both disposable)
which is better, to use:
try
{
using( SqlConnection conn = new SqlConnection(connString) )
{
using( SqlCommand comm = new SqlCommand() )
{
//...code lies here...
}
}
}
catch
{}
- OR -
having a try-catch-finally block surrounding my code and disposing the
objects in the finally clause?? or, should I dispose the objects
explicitly at all (just null 'em) ???
your thoughts appreciated on this...
regards,
Jon Oskar