title: C# - closing Sql objects best practice
body: <p>If you have a C# function with Sqlaccess, is it mandatory to close all objects/handles, or is everything cleaned up automatically once you exit the function</p>
  
  <p>For example:</p>
  
  <pre><code>void DoSqlStuff()
  {
      SqlConnection sqlConn = new SqlConnection(...);
      SqlCommand cmd = new SqlCommand(...);
      SqlDataReader sqlData= null;
  
      sqlConn,Open();
      sqlData = cmd.ExecutReader();
  
  
      while(sqlData.Read())
      {
           ...
      }
  }
  </code></pre>
  
  <p>Is it optional, recommended or mandatory to close SqlConn and SqlData?</p>
  
  <p>Thanks.</p>