19GreenBlankets 19GreenBlankets - 3 years ago 87
C# Question

update not working correctly on button

Good day, My code below is not working. What it was supposed to do is to update all record with

when button is clicked. I'm really new to this. I'm sorry.

using (MySqlConnection resetcon1 = new MySqlConnection(connString))
string scee = "WP";

MySqlCommand resetcom1 =
new MySqlCommand("UPDATE t_table SET scee=@scee WHERE scee ='RTP' ", resetcon1);

resetcom1.Parameters.AddWithValue("scee", scee);

Thank you so much.

Answer Source

The way it is here you will change scee to "WP" where scee is equal to "RTP".

 "UPDATE t_table SET scee=@scee WHERE scee ='RTP' "

If you want to do the opposite as mentioned in your question it should be:

 "UPDATE t_table SET scee='RTP' WHERE scee =@scee "

You might need to add '' like this too:

 "UPDATE t_table SET scee='RTP' WHERE scee ='@scee' "
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download