private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Invalid User"); } else { if (MessageBox.Show("Please Confirm Score Deletion :", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes) { String query = "DELETE FROM TopTen where Username ='******'"; SqlDataAdapter SDA = new SqlDataAdapter(query, con); SDA.SelectCommand.ExecuteNonQuery(); MessageBox.Show("Score Deleted Successfully!", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); if (MessageBox.Show("Delete User Account completely? ", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes) { DeleteUsers myform = new DeleteUsers(); this.Hide(); myform.ShowDialog(); this.Close(); } SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Select * from TopTen"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dataGridView1.DataSource = dt; } } }
//Delete Users private void button1_Click(object sender, EventArgs e) { DeleteUsers myform = new DeleteUsers(); this.Hide(); myform.ShowDialog(); this.Close(); }