Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Need confirmation before deleting the record

Need confirmation before deleting the record

Scheduled Pinned Locked Moved C#
questiondatabasemysqlhelpcareer
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    N Mohamed rafi
    wrote on last edited by
    #1

    I am trying to confirm before delete, if i give ok means it asks confirmation corectly and records also deleting but if i give no means it didn't showing Good, We keep this record safe this messagebox, what is the error in code? if (textBox6.Text!= "" && textBox7.Text != "" && textBox8.Text != "") { string connectionString; MySqlConnection cnn; connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql"; cnn = new MySqlConnection(connectionString); //string id = Convert.ToInt32(textBox6.Text); string id = textBox6.Text; string name = textBox7.Text; string salary = textBox8.Text; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; string query = "DELETE FROM employee WHERE employee_id=@employee_id AND employee_name=@employee_name AND employee_salary=@employee_salary"; //string query = "select * from employee"; using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Parameters.AddWithValue("@employee_id", id); cmd.Parameters.AddWithValue("@employee_name", name); cmd.Parameters.AddWithValue("@employee_salary", salary); cmd.Connection = cnn; cnn.Open(); cmd.ExecuteNonQuery(); DialogResult dr = MessageBox.Show("Are you sure to delete row?", "Confirmation", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { MessageBox.Show("Record Deleted Successfully"); cnn.Close(); DisplayData(); ClearData(); } else if (DialogResult == DialogResult.No) { MessageBox.Show("Good, We keep this record safe"); } } } else { MessageBox.Show("Please Select Record to Delete"); } }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups