>I got delphi several days ago and am trying to save the live data into a
>.dbf file. Sorry if this question has been asked.
>In SQL, you can do:
> INSERT INTO newtable
> SELECT * FROM oldtable
>Here newtable and oldtable have the same structure.
>Delphi BDE does not support this. What I want to know is how I can save a
>TQuery result into a .dbf file instead of live data in TDBGrid?
I am trying to do this as well. I am writing a Delphi CGI program
that will transfer dbase files across the network that match criteria
entered on a webpage.
The TQuery is nice, because I can dynamically specify the database at
runtime, and so the same program can access any of a number of databases.
What I started working on last night was to use a ttable object to
create a new database (using TTable.CreateTable) with the same structure
as the database I am querying. I would then use batch move to copy
The code goes something like this: (Source is a TQuery, NewTable a TTable)
With NewTable do
Active := False;
DataBaseName := 'c:\tempfile';
TableName := 'temp.dbf';
TableType := ttDefault;
FieldDefs := Source.FieldDefs;
The problem seems to be in the FieldDefs line. When I run this program
I (not surprisingly) get an exception saying "bad field def" at the
I am pretty sure that I need to copy the FieldDefs one by one to the
NewTable object. Unfortunately, it looks to me like I will have to
decompose the fielddefs from the TQuery since there is no Add(TFieldDef)
method for FieldDefs. That's my project for this afternoon.
I'll let you know if I have any luck.
Of course, any advice from someone who has done this before would be