All help gratefully received
Glyn
procedure dgExportTableDelimited(
DataSet: TDataSet;
AsciiFilePath: String;
Delimiter, Separator: Char);
{Exports a dataset as a delimited text file.
Parameters:
DataSet: The data to be exported.
AsciiFilePath: The text file path and name.
Delimiter: The character placed around non-
numeric field values, usually a
double quotation mark.
Separator: The character placed between
fields, usually a comma.
}
var
AsciiFile: System.Text;
I: Integer;
LastField: Integer;
begin
Assign(AsciiFile, AsciiFilePath);
Rewrite(AsciiFile);
LastField := DataSet.FieldCount - 1;
while not DataSet.EOF do
begin
for I := 0 to LastField do
begin
{If the field is not numeric write the opening
delimiter character.}
if not (DataSet.Fields[I].DataType in
[ftBCD, ftCurrency, ftFloat, ftInteger, ftSmallInt, ftWord])
then
Write(AsciiFile, Delimiter);
{Write the field value.}
Write(AsciiFile, DataSet.Fields[I].AsString);
{If the field type is not numeric write the
closing delimiter character.}
if not (DataSet.Fields[I].DataType in
[ftBCD, ftCurrency, ftFloat, ftInteger, ftSmallInt, ftWord])
then
Write(AsciiFile, Delimiter);
{If this is not the last field write the
separator character.}
if I < LastField then
Write(AsciiFile, Separator);
end; {for}
{Write the carriage/line feed at the end of
this record.}
Writeln(AsciiFile, '');
DataSet.Next;
end; {while}
System.Close(AsciiFile);
end;
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
http://sourceforge.net/projects/dbexpressplus
or our website.
--
Thomas Miller
Delphi Client/Server Certified Developer
BSS Accounting & Distribution Software
BSS Enterprise Accounting FrameWork
There a lot of file formats are supported including CSV/TXT, MS Excel,
HTML/XML, MS Word, MS Access, Lotus, ...
And you can export your any dataset (TClientDataset too, of course) in a few
mouse clicks...
--
With best regards, Mike Shkolnik
E-Mail: mshk...@scalabium.com
WEB: http://www.scalabium.com
Glyn Davies <gl...@cirrus.co.za> пишет в
сообщении:Xns92469427B52...@207.105.83.65...
> You might want to try TSQLDatapump
>
> http://sourceforge.net/projects/dbexpressplus
>
> or our website.
I have tried it but as far as I can see it does not support writing to an
ASCII file. Has this changed?
"Glyn Davies" <gl...@cirrus.co.za> wrote in message
news:Xns924CA791F342...@207.105.83.65...