0
Good morning.
I’m a beginner and I’m having problems with my Update. I wonder what I’m doing wrong.
public string Update(Usuario usuario)
{
var sql = new StringBuilder();
sql.Append("UPDATE TBUSU SET " + Environment.NewLine);
sql.Append($" SENHA = '{usuario.Senha}' ");
sql.Append($" ,EMAIL = '{usuario.Email}' ");
sql.Append($" ,TELEFONE = {usuario.Telefone} ");
sql.Append($" ,STATUS = '{(int)usuario.Status}' ");
sql.Append($" ,FUNCAO = '{(int)usuario.Funcao}' ");
sql.Append(" WHERE " + Environment.NewLine);
sql.Append($" NOME = '{usuario.Nome}' ");
var ret = Conexao.ExecutarComando(sql.ToString());
return ret;
}
I do not know if it is really necessary to use quotes, but in the phone you did not use, for example. You instead of using
var ret
can directly usereturn Conexao.ExecutarComando(sql.ToString());
. Try to see sql.Tostring() output as well and see how the string looks.– Kevin Kouketsu
A lot, especially a serious security problem. Correct: https://answall.com/q/202903/101 See tb https://answall.com/q/183975/101
– Maniero
Problems have several, as mentioned by Maniero... But what error are you getting?
– Leandro Angelo
It is not updating. Does not show error.
– Vinicius Marson
So... it could be yours
ExecutarComando()
or simply not finding any user as given name.– Leandro Angelo
Edit the question by presenting the changed code with the Maniero recommendations
– Leandro Angelo