Mohamed Rafi

Mohamed Rafi

  • NA
  • 74
  • 9k

MySql Query Error

Mar 22 2022 11:54 AM

I have stored userid and password in mysql database, this query is showing login successfully for not stored data, so please correct it

string query = "select * from login where userid=@userid and password=@password";
                 using (MySqlCommand cmd = new MySqlCommand(query))
                {
                   cmd.Parameters.AddWithValue("@userid", id);
                   cmd.Parameters.AddWithValue("@password", password);
                    cmd.Connection = cnn;
                    cnn.Open();
                    cmd.ExecuteNonQuery();
                    DialogResult dr = MessageBox.Show("Are you sure to Login now?", "Confirmation Message", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.Yes)
                    {
                        MessageBox.Show("Login Successfully");
                        cnn.Close();
                        this.Hide();
                        Form2 f2 = new Form2();
                        f2.ShowDialog();


Answers (1)