Error changing old database data

Asked

Viewed 40 times

1

With the help of this reply I was able to edit the data I enter in the database, but the old data that is already registered, when I try to change the registration, the program continues to close alone and when debugging displays the following error message.

inserir a descrição da imagem aqui

And if I keep debugging the mistake it becomes:

inserir a descrição da imagem aqui

I was debugging the code and the error is occurring in procedure Upload_ftp, mine procedure this way:

procedure TfrmCriarArquivo.Envio_ftp(grupo, cliente: string);
begin
  with FTP do try
    Username := frmMenu.usuario;
    Password := frmMenu.senha;
    Host := frmMenu.endereco;
    Port := StrtoInt(frmMenu.porta);
    Connect;
    try
      ChangeDir(grupo);
    except
      FTP.MakeDir(grupo);
      ChangeDir(grupo);
    end;
    try
      FTP.Put('dados.ini', 'dados.ini', false);
    except
    end;
    try
      ChangeDir(grupo + '/' + cliente);
    except
      FTP.MakeDir(grupo + '/' + cliente);
      ChangeDir(grupo + '/' + cliente);
    end;
  except
    application.Terminate;
  end;
  try
    FTP.Put(cliente + '.xml', cliente + '.xml', False);
    FTP.Put('Tags' + '_' + cliente + '.txt', 'Tags' + '_' + cliente + '.txt', false);
  finally
    FTP.Disconnect;
  end;
  DeleteFile(cliente + '.xml');
  DeleteFile('Tags' + '_' + cliente + '.txt');
  DeleteFile('dados.ini');
end; 

Remembering that this only happens when I try to change the old bank records.

New Error:

inserir a descrição da imagem aqui

and how was the procedure after the change:

with FTP do try
    Username := frmMenu.usuario;
    Password := frmMenu.senha;
    Host := frmMenu.endereco;
    Port := StrtoInt(frmMenu.porta);
    Connect;
    try
      ChangeDir(grupo);
    except
      FTP.MakeDir(grupo);
      ChangeDir(grupo);
    end;
    try
      FTP.Put('dados.ini', 'dados.ini', false);
    except
    end;
    try
      ChangeDir(grupo + '/' + cliente);
    except
      FTP.MakeDir(grupo + '/' + cliente);
      ChangeDir(grupo + '/' + cliente);
    end;
  except
    application.Terminate;
  end;
  • Looking over the top, the only place that makes sense to meet this source is at StrtoInt. Are you sure frmMenu.porta is filled?

  • @Genos I’m a beginner in Delphi and this code is legacy, I will now debug the code again and when I step the mouse cursor over that line frm.porta show me ''

1 answer

2


EConvertError (the exception indicated in your message) usually happens when you try to convert one type of value into another. In your case it’s happening because of the line:

StrtoInt(frmMenu.porta)

StrToInt is a method that converts a string to an integer number. As commented, frmMenu.porta contains the value ''(empty string). As the method cannot convert '' for a number, this error happens.

To resolve, identify if it is indeed possible frmMenu.porta be empty.

  • If yes, check the value of the field before conversion and treat it:

    if frmMenu.porta = '' then
      // Por exemplo, usar uma porta padrão...
      Port := 20
    else
      Port := StrtoInt(frmMenu.porta);
    
  • Otherwise, identify why the field frmMenu.porta be empty and resolve this situation.
  • I made the change you suggested in your reply and made a different mistake during the execution and continued to close the application. I edited the original question with the new bug image

  • Ai is probably connection error, check if you are using the right host/port, among other settings. No more detailed information is as much as I can help you.

Browser other questions tagged

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