0
Whoa, whoa, guys, whoa. Newbie here
Every time I click on change and then click on save (without making changes of record) returns me error . Any idea how to fix? some kind of check on whether there has been any change make, otherwise disregard.
Ah, I’m using Delphi7 and Zeoslib connected to mysql
{EDIÇÃO DE REGISTRO}
if Ativo = False then
begin
if cpfantigo <> txtcpf.text then
begin
dm.query_func.Close;
DM.Query_func.SQL.Clear;
DM.Query_func.SQL.Add('SELECT * from funcionarios where cpf = ' + quotedstr(trim(txtcpf.Text)));
DM.Query_func.Open;
if not dm.query_func.isEmpty then
begin
cpf := txtcpf.text;
MessageDlg('O CPF ' + cpf + ' Já está cadastrado no sistema',mtInformation,[mbOK],0) ;
txtcpf.SetFocus;
txtcpf.clear;
btnNovo.enabled := True;
exit;
end;
end;
associarCampos;
Dm.Query_func.Close;
DM.Query_func.SQL.Clear;
DM.Query_func.SQL.Add('UPDATE funcionarios SET nome = :nome ,cpf = :cpf , endereco = :endereco, telefone = :telefone, cargo = :cargo where ID = :id') ;
DM.Query_func.ParamByName('nome').Value := txtnome.text;
DM.Query_func.ParamByName('CPF').Value := txtcpf.text;
DM.Query_func.ParamByName('ENDERECO').Value := txtendereco.text;
DM.Query_func.ParamByName('TELEFONE').Value := txttel.text;
DM.query_func.ParamByName('cargo').Value := cbcargos.text;
DM.Query_func.ParamByName('ID').Value := id;
DM.Query_func.ExecSQL;
MessageDlg('Editado com sucesso',mtInformation,[mbOK],0);
listar;
end;
Thank you in advance
Edgar, I have a suggestion. Place this code block inside a "Try...Exception", then capture the exception code it returns. Then you put an "IF" and evaluate if the code is different from the exception, gives a message, or lets "go on life", without locking the application. That wouldn’t depend on standing around and assessing whether something’s been changed. There may be something better to work on, but right now that’s my suggestion.
– Rodrigo Tognin
I had to redo the connection using another component, but it flowed.
– Edgard Araújo