title: "ExecuteReader requires an open and available Connection. The connection's current state is closed." on WebForm
body: <p>I am wiorking on a web application when i click on to fetch data from database i get the following error: </p>
  
  <p>ExecuteReader requires an open and available Connection. The connection's current state is closed.</p>
  
  <blockquote>
    <p>ExecuteReader requires an open and available Connection. The
    connection's current state is closed.</p>
  </blockquote>
  
  <p>I declare my connection on a seperate class as the following: </p>
  
  <pre><code>public Database()
  {
      valid = false;
  
      using (connection = new SqlConnection(connectionString))       
      {                  
          connection.Open();
      }    
  }
  </code></pre>
  
  <p>Where i get the error: </p>
  
  <p><a href="https://i.stack.imgur.com/lqCZG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lqCZG.png" alt="enter image description here"></a></p>
  
  <p>and i call it from a WebForm. Why do i get this error when the connection is already open (I used to use odbc connection and it works fine, however the SqlConnection is not working)</p>
  
  <p>What is the reason? </p>