I want to update "todo" in table user, where the value "username" is the same as the value in my code _naam. What I have so far (kind of copied from my "read" command):
private bool Todo_updaten(string _todo)
{
db_connection();
MySqlCommand cmdUpdate = new MySqlCommand();
cmdUpdate.CommandText = "UPDATE `user` SET `todo`=@todo 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;
}
I get an error at my bool todo_updaten, which says: not all code paths return a value.
returnat method's end.false, I suppose, given your logic. Yours only returns if the code enters the block, so it's not lying to you.return truestatement is inside yourif (tbupdaten.Read()). Be sure to return something outside as well. e.g.else { return false; }