private void button2_Click(object sender, EventArgs e) { Password p = new Password(); p.ShowDialog(); if (p.getResult() == true) { MessageBox.Show("Correct"); string dr = dataGridView1.CurrentRow.Cells[0].Value.ToString(); if (dr == "G 001" || dr == "0") { MessageBox.Show("Unable to delete user! You are trying to delete 'usual user' or 'G 001'","Error!",MessageBoxButtons.OK,MessageBoxIcon.Error); } else { SqlCommand deleteUser = new SqlCommand("DELETE FROM customer WHERE customer_id=@customer_id;", con); deleteUser.Parameters.Add(new SqlParameter("@customer_id", SqlDbType.VarChar)); deleteUser.Parameters["@customer_id"].Value = dataGridView1.CurrentRow.Cells[0].Value.ToString(); deleteUser.ExecuteNonQuery(); updateData(); } } else MessageBox.Show("Wrong password"); //MessageBox.Show(dataGridView1.Rows[clicked_row].Cells[0].Value.ToString()); }