Board index » delphi » How to: copy a record from one table to another one

How to: copy a record from one table to another one

Hi,
The scenario is based on Paradox7
I like to copy one record from table1 to table2,
but I don't know at compile time the structure
of table1. Table1 and table2 has the same structure.

I imagine something like:

table2.append
for each field in table1 do
 replace the field in table2 with the content of the field from table1

Ok, but how can do that if I don't know the type and names of each field?
Some code snippet is welcome.
Thanks in advance

Mauricio

 

Re:How to: copy a record from one table to another one


var
  I:    Integer
begin
  Table2.Insert;
  for I := 0 to Table1.FieldCount - 1 do
    Table2.Fields[I].Assign(Table1.Fields[I]);
  Table2.Post;

--
Bill

Re:How to: copy a record from one table to another one


Hi,
great!
Thank you Bill

Bill Todd (TeamB) <billtodd...@nospam.qwest.net> escribi en el mensaje de
noticias 3abe0dd3$1_2@dnews...

Quote
> var
>   I:    Integer
> begin
>   Table2.Insert;
>   for I := 0 to Table1.FieldCount - 1 do
>     Table2.Fields[I].Assign(Table1.Fields[I]);
>   Table2.Post;

> --
> Bill

Other Threads