title: Why use a using statement with a SqlTransaction?
body: <p>I've been running into some problems concerning a SqlTransaction I'm using in my code. During my Googling I see many people using a using statement with a SqlTransaction.</p>
  
  <p>What is the benefit and/or difference of using this type of statement with a SqlTransaction?</p>
  
  <pre><code>using (SqlConnection cn = new SqlConnection())
  {
       using (SqlTransaction tr = cn.BeginTransaction())
       {
        //some code
        tr.Commit();
       }
  }
  </code></pre>
  
  <p>Currently my code looks like this:</p>
  
  <pre><code>SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["T3"]);
  cn.Open();
  SqlTransaction tr = cn.BeginTransaction();
  
  try
  {
       //some code
       tr.Commit();
       cn.Close();
  }
  catch(Exception ex)
  {
        tr.Rollback();
        cn.Close();
        throw ex;
  }
  </code></pre>
  
  <p>What is the advantage of one way over the other?</p>