更新在按钮上无法正常工作

问题描述:

美好的一天,我的下面的代码无法正常工作。当按钮被点击时,它应该做的是将所有记录更新为scee='WP''RTP'。我真的很陌生。对不起。更新在按钮上无法正常工作

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

    MySqlCommand resetcom1 = 
     new MySqlCommand("UPDATE t_table SET [email protected] WHERE scee ='RTP' ", resetcon1); 

    resetcom1.Parameters.AddWithValue("scee", scee); 
    resetcom1.ExecuteNonQuery(); 
    resetcon1.Close(); 
} 

非常感谢。

+0

无需添加参数。如果我正确理解你的话,你的sql命令应该看起来更像这样:UPDATE t_table SET scee ='RTP'WHERE scee ='WP' – kristech

+0

我会试试看!先生!〜 – 19GreenBlankets

就是这样,你将把scee改变为scee等于“RTP”的“WP”。

"UPDATE t_table SET [email protected] WHERE scee ='RTP' " 

如果你想要做相反在你的问题中提到它应该是:

"UPDATE t_table SET scee='RTP' WHERE scee [email protected] " 

您可能需要添加'这样太:

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