public void delete() { DialogResult result = MessageBox.Show("Do you really want to Delete this Product", "Confirm product Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConnectionClass.DeleteCommand("Delete from Category where Category_id=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); MessageBox.Show("Account Deleted Successfully!"); dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from Category"); } }