title: Does closing a database connection in Dispose method is right?
body: <p>I've had a suspicion that a database connection used in one of our applications is not always closed. I went to see the code and I've found a class <code>DataProvider</code> that has <code>SqlConnection</code> object. The connection is opened in the constructor of this class and closed in it's <code>Dispose</code> method (don't judge that, I know keeping an open connection is evil, it's just not my code and it's not the point of the question anyway). The <code>Dispose</code> method is implemented like this:</p>
  
  <pre><code>protected virtual void Dispose(bool disposing)
  {
      if (!_disposed)
      {
          if (disposing)
          {
              if (_conn != null)
                  _conn.Close();
          }
  
          _disposed = true;
      }
  }
  </code></pre>
  
  <p>The question is:<br>
  Does it always guarantee that the connection is closed?<br>
  Is this code right?  </p>
  
  <p>I think there should be <code>_conn.Dispose()</code> called - am I right and could it affect not closing the connection (probably not)?</p>