UPDATE syntax error in Delphi (Mysql)

Asked

Viewed 263 times

2

Good evening... I am using a procedure in msm style for all modules of my software using msm UPDATE structure and all worked, however when I went to do the update of system users this returning me the error : incorrect UPDATE command syntax... will I leave the code down someone please know what is happening? thank you

    procedure TModulo.EditarUsuario(idPr: Integer; userPr: string; senhaPr:        string);
    begin

   with reserva do begin

       Close;
        SQL.Clear;
        SQL.Add('UPDATE usuarios SET user = :userPr, senha = :senhaPr ' +
    'where id = ' + IntToStr(idPr));

        Parameters.ParamByName('userPr').Value := userPr;
        Parameters.ParamByName('senhaPr').Value := senhaPr;

        ExecSQL;

    end;

      //resetando para visualização
      DMDados.Modulo.reserva.close;
      DMDados.Modulo.reserva.sql.Clear;
      DMDados.Modulo.reserva.sql.Add('select * from usuarios');
      DMDados.Modulo.reserva.open;
      //resetando para visualização</>

    end;
  • Put the mistake you’re making together

  • Error in the SYNTAX of the UPDATE statement only this

  • I think I’m missing put the user and password in quotes.

1 answer

3


From what I could observe, just said specify the ID in Parambyname

reserva.Close;
reserva.SQL.Clear;
reserva.SQL.Add('UPDATE USUARIOS SET');
reserva.SQL.Add('USER = :USERPR,');
reserva.SQL.Add('SENHA = :SENHAPR');
reserva.SQL.Add('WHERE ID = :IDPR');

reserva.ParamByName('IDPR').AsInteger := idPr;
reserva.ParamByName('USERPR').AsString := userPr;
reserva.ParamByName('SENHAPR').AsString := senhaPr;
reserva.ExecSQL;
  • Guy tried here but did not find the asstring function

  • You must declare in use Data.DB

  • vixi this error ta cabuloso tb n was funny kk that in the other modules I used the same structure in the update and it was normal only in this table that is bad

  • has how to backup this table and create again

  • beauty I’ll try to recreate later

  • Three things... 1.) Before the command ExecSql execute the command SQL.SaveToFile('arquivo.txt') and send us the result. 2.) How is the table structured? And 3.) Debugging the code, how are the variables filled idPr, userPr and password?

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.