The following 2 sets of codes produce same results, but I'm wondering which of these is the correct way of wrapping with the try...catch block. What's the difference between the 2 of them?
Edited: Which of this will properly capture the error, and also to make sure the connection will be closed even if there is an exception.
1
try
{
    using (SqlConnection conn = new SqlConnection(connString))
    {
        SqlCommand cmd = new SqlCommand("Drop Table sometable", conn);
        cmd.Connection.Open();
        cmd.ExecuteNonQuery();
    }
}
catch
{
    //
}
2
using (SqlConnection conn = new SqlConnection(connString))
{
    try
    {
        SqlCommand cmd = new SqlCommand("Drop Table sometable", conn);
        cmd.Connection.Open();
        cmd.ExecuteNonQuery();
    }
    catch
    {
        //
    }
}
 
     
     
     
     
     
    