title: MySqlDataReader in C# has no rows
body: <p>I'm trying to develop a little user-user messaging system in C# (my first C# app) using a mysql database.</p>
  
  <p>I know best practice would be to use something like EF for working with the database, but I'm writing this the "stupid" way just to get comfortable with the syntax.</p>
  
  <p>I come from a vb background so I'm basically just converting what I normally do in vb and that's why I can't understand why, despite having a matching row in my database, the DataReader keeps coming back with no rows. See below:</p>
  
  <pre><code>    protected void btnLogin_Click(object sender, EventArgs e)
      {
          Page.Validate("Login");
  
          if (!IsValid)
          {
              return;
          }
  
          if (checkLogin())
          {
              Response.Redirect("Default.aspx");
          }
          else
          {
              lblErr.Text = "Invalid login attempt";
          }
      }
  
      protected Boolean checkLogin()
      {
          MySql db = new MySql();
  
          string sql = "select userid, firstname, lastname, ifnull(lastlogin, '') from users where email = @email and pass = @pass";
  
          List&lt;MySqlParameter&gt; args = new List&lt;MySqlParameter&gt;();
          args.Add(new MySqlParameter() { ParameterName = "@email", MySqlDbType = MySqlDbType.VarChar, Size = 100, Value = txtEmail.Text });
          args.Add(new MySqlParameter() { ParameterName = "@pass", MySqlDbType = MySqlDbType.VarChar, Size = 20, Value = txtPass.Text });
  
          MySqlDataReader dr = db.getReader(sql, args);
  
          if (dr.HasRows)
          {
              dr.Read();
  
              Session["userid"] = dr.GetInt32("userid");
              Session["firstname"] = dr.GetString("firstname");
              Session["lastname"] = dr.GetString("lastname");
              Session["lastlogin"] = dr.GetDateTime("lastlogin");
  
              dr.Close();
  
              return true;
          }
          else
          {
              return false;
          }
      }
  </code></pre>
  
  <p>The above code checks the user input against the database and returns a row if there are any rows in the table that match the user input...</p>
  
  <p>Here's the code for the interaction with the database...</p>
  
  <pre><code>public class MySql
  {
      static string connStr = "data source=localhost; initial catalog=mail; user id=root; password=Ly@12157114;";
      MySqlConnection conn = new MySqlConnection(connStr);
  
      public MySqlDataReader getReader(string sql, List&lt;MySqlParameter&gt; args)
      {
          if (args.Count == 0)
          {
              return getReader(sql);
          }
          else
          {
              return getReader(sql, args.ToArray());
          }
      }
      public MySqlDataReader getReader(string sql, MySqlParameter[] args = null)
      {
          MySqlCommand cmd = new MySqlCommand(sql, conn);
  
          if (args != null)
          {
              cmd.Parameters.AddRange(args);
          }
  
          conn.Open();
  
          MySqlDataReader dr = cmd.ExecuteReader();
  
          conn.Close();
  
          return dr;
      }
  }
  </code></pre>
  
  <p>I get no errors or any indication that something has gone wrong here and I'm positive there is data that match my input into the login fields.</p>
  
  <p>Can anyone help me to understand why the DataReader keeps coming back empty?</p>