我想在表用戶中更新「todo」,其中值「username」與我的代碼_naam中的值相同。我有什麼到目前爲止(從我的「讀」命令那種複製):並非所有的代碼路徑返回值:使用C#在MySQL中更新值數據庫#
private bool Todo_updaten(string _todo)
{
db_connection();
MySqlCommand cmdUpdate = new MySqlCommand();
cmdUpdate.CommandText = "UPDATE `user` SET `todo`[email protected] WHERE `username` LIKE '" + _naam + "'";
cmdUpdate.Parameters.AddWithValue("@todo", _todo);
cmdUpdate.Connection = connect;
MySqlDataReader tbupdaten = cmdUpdate.ExecuteReader();
if (tbupdaten.Read())
{
tbTodo.Text = tbupdaten.GetString(0);
connect.Clone();
return true;
}
我在布爾todo_updaten,它說得到一個錯誤。
在方法結尾添加另一個'return'。假設,假設你有邏輯。你的_只返回_if_代碼進入該塊,所以它不會騙你。 – DonBoitnott
你的'return true'語句在你的'if(tbupdaten.Read())'裏面。一定要回到外面去。例如'else {return false; }' –