title: Best way for SqlConnection inside a loop
body: <p>I am processing about 24k records totally per day in a windows service, I insert the rows into a database and then I save image compressed in a directory.</p>
  
  <p>Generally, what is the best way for this?</p>
  
  <pre><code>using (SqlConnection cnn = new SqlConnection())
  {
      foreach (var item in collection)
      {
          //do stuff 
  
          SaveImage(item.filename,item.img);
      }
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>foreach (var item in collection)
  {
      using (SqlConnection cnn = new SqlConnection())
      {
          //do stuff
      }
  
      SaveImage(item.filename, item.img);
  }
  </code></pre>
  
  <p>Thanks</p>