--- In [email protected], Marselle Caston <[EMAIL PROTECTED]> wrote:
> Is there anyone out there who has written a Dataset to
> Textfile routine I need to be able to design a program
> that will allow users to select particular fields from
> a table or query and then export the results into a
> textfile so that they can import the export file into
> another database table. since excel only supports 65k
> total files this will not help.. any suggestions 
> 
> thanks
> 
> MC

For writing to textfiles, you can use the procedures 
AssignFile/Rewrite/Write/WriteLn/CloseFile to write the fields to a 
textfile.

To walk through a dataset, you use the methods 
Dataset.First/Dataset.Next in a while loop. And accessing the fields in 
this dataset should not be a problem for you either, I think. You'd get 
something like this:

var 
  AFile:Textfile;
  FieldNames: array of string;
  I: Integer;
begin
  // Fill FieldNames with the names of the fields you want to be 
printed.
  AssignFile(AFile, 'Data.csv');
  Rewrite(AFile);
  Dataset.First;
  while not Dataset.EOF do begin
    I := Low(FieldNames);
    // Write all fields except last one.
    while (I < High(FieldNames)) do begin
      Write(AFile, Dataset.FieldByName(FieldNames[I]).AsString, ',');
      Inc(I);
    end;
    // Write last field!
    WriteLn(AFile, Dataset.FieldByName(FieldNames[I]).AsString);
    // Next record.
    Dataset.Next;
  end;
  CloseFile(AFile);
end;

As you can see, you don't need any component to convert a dataset to a 
CSV file.

With kind regards,
X Katja Bergman.





-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to