title: How to fix this? "Invalid attempt to call CheckDataIsReady when reader is closed"
body: <p>I created a constructor method to execute sqldatareader to avoid retyping sqlconnection but there's an error when I use it:</p>
  
  <pre><code>public SqlDataReader ExecuteCommand(string cmdText, CommandType cmdType)
  {
      SqlDataReader dr = null;
      using (SqlConnection conn = new SqlConnection(ConnString))
      {
          SqlCommand cmd = conn.CreateCommand();
          cmd.CommandText = cmdText;
          cmd.CommandType = cmdType;
          try
          {
              if (conn.State != ConnectionState.Open)
              {
                  conn.Open();
                  dr = cmd.ExecuteReader();
              }
          }
          catch(Exception e)
          {
  
          }
          finally
          {
              dr.Dispose();
              conn.Close();
          }
      }
      return dr;
  }
  </code></pre>
  
  <p>I try to use it but the error occurs:</p>
  
  <pre><code>SqlDataReader dr = ExecuteCommand("Select * from EmployeeInfo where Employeeid = 2", CommandType.Text);
  textBox1.Text = dr[1].ToString();
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>Invalid attempt to call CheckDataIsReady when reader is closed.</p>
  </blockquote>