title: Working on "using" statement in ADO.NET
body: <p>I want to properly dispose the SqlConnection object whenever i come out of the method. So im using the "using" statement as shown below.</p>
  
  <pre><code>public int Hello()
  {
     using(SqlConnection con=new SqlConnection(constring))
     {
        using(SqlCommand cmd=new SqlCommand(Query,con))
        {
         try
         {
            con.Open();
            return cmd.ExecuteNonQuery();
         }
         catch(Exception ex)
         {
            throw ex;
         }
         finally
         {
            con.Close()
         }
        }
     }
  }
  </code></pre>
  
  <p>Now, what i want to know is, Will the above code </p>
  
  <ol>
  <li>Dispose the Connection properly when an <strong>Exception</strong> is occured in ExecuteNonQuery.</li>
  <li>Make sure we will not get any ConnectionPool issues</li>
  <li>Make sure the data is returned properly</li>
  <li>If an exception occurs in SqlConnection will it dispose the object?</li>
  </ol>
  
  <p>Can anyone help me on this?</p>