private void button1_Click(object sender, EventArgs e) { My_DB db = new My_DB(); MySqlDataAdapter adapter = new MySqlDataAdapter(); DataTable table = new DataTable(); MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `username` = @usn AND `password` = @pass", db.getconnection); command.Parameters.Add("@usn", MySqlDbType.VarChar).Value = textBox1.Text; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBox2.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Please Enter Valid Credentials..."); } }