title: Invalid attempt to call HasRows when reader is closed
body: <p>I have this problem: Invalid attempt to call HasRows when reader is closed.
  I have tried alot; removing connection close line, closing the connection in the end. but having same issue. I can't get whats wrong with my code.</p>
  
  <pre><code>try
  {
      con = new SqlConnection(ConfigurationManager.ConnectionStrings["TextItConnectionString"].ConnectionString);
      using (con)
      {
          con.Open();
          Library.writeErrorLog("connection build and open");
          SqlCommand cmd = con.CreateCommand();
          using (cmd)
          {
              cmd.CommandText = "Select [name] From [dbo].[Users]";
              SqlDataReader reader = cmd.ExecuteReader();
              using (reader)
              {
                  user.dt.Load(reader);
                  if (reader.HasRows)
                  {
                      while (reader.Read())
                      {
                          Library.writeErrorLog(reader.GetString(0));
                      }
                  }
                  else
                      Library.writeErrorLog("no rows");
                  reader.Close();
                  con.Close();
              }
          }
      }
      //SqlDataAdapter adap = new SqlDataAdapter("Select [name] From [dbo].[Users]", con);
      //adap.Fill(user.dt);
  }
  catch (Exception ex)
  {
      Library.writeErrorLog(ex);
  }
  </code></pre>
  
  <p>Thanks for the help!</p>