2017-07-24 62 views
0

美好的一天,我的下面的代碼無法正常工作。當按鈕被點擊時,它應該做的是將所有記錄更新爲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

回答

1

就是這樣,你將把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' "