1
I need to save the result of a query inside the txt file by separating by a delimiter, I am extremely new to Delphi and Firebird, so any help is welcome
code below:
procedure TForm1.btPesquisarClick(Sender: TObject);
var arquivo: TextFile;
var dados: string;
var I: Integer;
begin
if EdLoja.Text = '' then
begin
IBQuery1.Close;
IBQuery1.SQL.Clear;
IBQuery1.SQL.Add('select COUNT(CDLOJA) from lojas');
IBQuery1.Open;
while not IBQuery1.eof do
begin
IBQuery2.Close;
IBQuery2.SQL.Clear;
IBQuery2.SQL.Add('select * from lojas where CDLOJA = '+(EdLoja.Text)+'');
IBQuery2.SQL.Add('and p.cdloja = '+(IBQuery1.Eof)+'');
IBQuery2.SQL.Add('and p.dtlancamento >= '+ FormatdateTime('mm"-"dd"-"yyyy',StrToDate(EdDataIni.Text)) + '');
IBQuery2.SQL.Add('and p.dtlancamento <= '+ FormatdateTime('mm"-"dd"-"yyyy',StrToDate(EdDataFim.Text)) + '');
IBQuery2.Open;
IBQuery2.First;
AssignFile(arquivo, 'c:\\'+IBQuery2.FieldByName('CDLOJA').AsString+'Vencimento.txt');
Rewrite(arquivo);
dados := IBQuery2.FieldByName('CDLOJA').AsString + ';' + IBQuery2.FieldByName('CDBAIRRO').AsString;
WriteLn(arquivo, dados);
IBQuery2.Next;
CloseFile(arquivo);
end;
ShowMessage('ARQUIVOS GERADO COM SUCESSO!');
end;
end;
end.
Ezequiel, you have some problems in your question and one of them is code formatting, for this edit and use Ctrl+K. It would be nice to improve, to avoid closing and always try to ask questions that will be useful to others in the community, see [Ask].
– Melissa