title: InvalidOperationException: no current row error
body: <p>I am getting this error on my login form. I am unsure on fixing it because I do not know what's wrong.</p>
  
  <blockquote>
    <p>InvalidOperationException: no current row</p>
  </blockquote>
  
  <p>When I start the app, it crashes.</p>
  
  <p><a href="https://i.stack.imgur.com/bbuz1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bbuz1.png" alt="enter image description here"></a></p>
  
  <pre><code>     private void buttonLogin_Click(object sender, EventArgs e)
      {
           SQLiteConnection conn = new SQLiteConnection("data source = zivali_v2.sqlite");
           conn.Open();
           SQLiteCommand com = new SQLiteCommand(conn);
  
           com.CommandText = "SELECT * FROM login;";
  
           SQLiteDataReader reader = com.ExecuteReader();
  
               string username = reader["username"].ToString();
               string password = reader["password"].ToString();
  
           bool loginValid = false;
           while (reader.Read())
           {
               if (username == textBoxUserName.Text &amp;&amp; password == textBoxPassword.Text)
               {
                   loginValid = true;
                   break;
  
               }
           }
  
           if (loginValid)
           {
               MessageBox.Show("OK");
           }
           else
           {
               MessageBox.Show("Wrong username or password");
           }
           conn.Close();
  
      }
  </code></pre>