Domanda

How to export Delphi BDE Paradox *.db Query Result to a text file? e.g. I use SQL Explorer or Database Dekstop in Borland Delphi and the query like : SELECT * FROM mst_employee;

and I want the result of the query in a text file say mst_employee.txt something like :

employee_code;name;status;
001;Andi;1;
002;Budi;2;
003;Carli;3;

Thanks before

È stato utile?

Soluzione

I would iterate over the result set returned by the query and write the results to a text file, delimiting each file with a semicolon. I'm not aware of any built-in functionality which would do this.

with query do
 begin
  params[0].asinteger:= <whatever>;
  open;
  if not isempty then
   begin
    assignfile (f, 'c:\data.txt');
    rewrite (f);
    while not eof do
     begin
      writeln (f, fieldbyname ('a').asstring, ';', fieldbyname ('b').asstring, ';');
      next
     end;
    closefile (f);
   end;
  close
 end;

Apologies for old-style Pascal I/O, but if we're still using the BDE.....

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top