title: How to optimally handle sql connections in vb.net?
body: <p><strong>ASP.NET WEB PROGRAMMING</strong></p>
  
  <p>How to optimally handle </p>
  
  <ul>
  <li>Open </li>
  <li>Close</li>
  <li>Dispose</li>
  <li>Exception</li>
  </ul>
  
  <p>when retrieving data from a database.</p>
  
  <p><strong>LOOKING TO OPTIMISE</strong></p>
  
  <p>I have always used the following to make a connection, catch any errors, and then correctly dispose of the connection in either event.</p>
  
  <p><strong>VB.NET</strong></p>
  
  <pre><code>Try
    con.Open()
    //...
    con.Close()
  Catch ex As Exception
    lbl.Text = ex.Message
  Finally
    If con IsNot Nothing Then
      con.Dispose()
    End If
  End Try
  </code></pre>
  
  <p>After reading many articles I find people practically throwing up at this code; however, I do not see any other way to accomodate the four steps required <strong>efficiently</strong>.</p>
  
  <p>The alternative, and I believe more cpu friendly <strong><code>USING</code></strong> statement, seems to be the tool of choice for the correct disposal of a sql connection. But what happens when bad data is retrieved from the database and there is nothing in place to indicate to an end user what went wrong?</p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>Between: <strong>Using</strong>, <strong>try catch</strong>, and <strong>other</strong>.</p>
  
  <p>Which is faster, cleaner, and/or most efficient way to handle a data retrieval statement?</p>
  
  <p><em>I am happy to hear people's opinions but I am looking for facts.</em></p>