private void button1_Click(object sender, EventArgs e) { Boolean b = false; con.Open(); string s = "select * from receptionist "; MySqlCommand cmd = new MySqlCommand(s, con); MySqlDataReader d = cmd.ExecuteReader(); while (d.Read()) { string username = d["rName"].ToString(); string password = d["rpassword"].ToString(); if ((username == textBox1.Text) && (password == textBox2.Text)) { b = true; } } if (b == false) { MessageBox.Show("Invalid Click (Ok) to try again"); } else { Receptionist_Form rform = new Receptionist_Form(); this.Hide(); rform.ShowDialog(); } con.Close(); }