Board index » delphi » How to copy TTable, record by record

How to copy TTable, record by record

I want to read a record from Table1 (BDE/Paradox), make some changes, and
append it to Table2.

while not Table1.eof do
  Table2.Append
  CopyRecordToTable2's buffer
  Table2.FieldByName["Name"].AsString := 'New String';  // make some changes
to the record like this...
  Table2.Post
  Table1.Next

CopyRecordToTable2's should copy a record from Table1 to Table2's  buffer.
The record has about 120 fields, so I'd like it to be fast. What's the
fastest (high-level, not dbi...) way to do this?

 

Re:How to copy TTable, record by record


for I := 0 to SourceTbl.FieldCount - 1 do
  DestTbl.Fields[I].Assign(SourceTbl.Fields[I]);

--
Bill

Re:How to copy TTable, record by record


How about if I want to store all the fields to a temporary place for later
use? Is there any simple way to do this? I ask this because, e.g., I want to
append a new record with all the field values duplicated from a certain
record in the same table and let user to modify.

Regards,

Joseph Liu

"Bill Todd (TeamB)" <billtodd...@nospam.qwest.net> wrote in message
news:3b1bcbbe$1_1@dnews...

Quote
> for I := 0 to SourceTbl.FieldCount - 1 do
>   DestTbl.Fields[I].Assign(SourceTbl.Fields[I]);

> --
> Bill

Re:How to copy TTable, record by record


You can use two TTables connected to the same database table and the code in
my las message. Another way is to copy the record field by field to a
variant array, change the values you want to change then copy the variant
array elements to the new record.

--
Bill

Other Threads