Board index » delphi » Copying fields/records from query to table

Copying fields/records from query to table

D2.0, C/S, W95
Is there an easier way to copy fields from a query to a table than (eg):
dmData.taCustomerCustName.AsString:=dmData.quCustomerCustName.AsString;
This does work but is very cumbersome when there are many fields in the
table.
I'm sure there must be a simple way to copy all fields in one go.
All suggestions welcome. TIA
David Carle.

 

Re:Copying fields/records from query to table


This solution work on Delphi 3 Professional
and I think that must work on Delphi 2 C/S

batchmove1.source:=query1;
batchmove1.destination:=table1;
batchmove1.execute;

For more information see help for batchmove component.

                        Zdravko Dokuzovic
                        Slavonski Brod, Croatia
                        e-mail: zdoku...@barok.foi.hr

Quote
David Carle wrote in message <34DD03C5....@clara.net>...
>D2.0, C/S, W95
>Is there an easier way to copy fields from a query to a table than (eg):
>dmData.taCustomerCustName.AsString:=dmData.quCustomerCustName.AsString;
>This does work but is very cumbersome when there are many fields in the
>table.
>I'm sure there must be a simple way to copy all fields in one go.
>All suggestions welcome. TIA
>David Carle.

Re:Copying fields/records from query to table


Quote
David Carle wrote:

> D2.0, C/S, W95
> Is there an easier way to copy fields from a query to a table than (eg):
> dmData.taCustomerCustName.AsString:=dmData.quCustomerCustName.AsString;
> This does work but is very cumbersome when there are many fields in the
> table.
> I'm sure there must be a simple way to copy all fields in one go.
> All suggestions welcome. TIA
> David Carle.

It's also some lines of code, but only 3 or 4 :

With dmData do
  For i:=0 to taCustomer.FieldCount-1 do
    taCustomer.FieldByName(quCustomer.Fields[i].FieldName).Value:=
      quCustomer.Fields[i].Value;

You have to be careful about the Field count and if you choose the good
field in each dataset.
If Value does not work, you can use AsVariant. AsString work with 90%
kinds of fields.

Hope this will be the right answer.

Frdric GUILLIEN.

Re:Copying fields/records from query to table


David Carle a crit dans le message <34DD03C5....@clara.net>...

Quote
>D2.0, C/S, W95
>Is there an easier way to copy fields from a query to a table than (eg):
>dmData.taCustomerCustName.AsString:=dmData.quCustomerCustName.AsString;
>This does work but is very cumbersome when there are many fields in the
>table.
>I'm sure there must be a simple way to copy all fields in one go.
>All suggestions welcome. TIA
>David Carle.

I use

With dmData do
  For i:=0 to taCustomer.FieldCount-1 do
    taCustomer.Fields[i].Assign(quCustomer.Fields[i]);

works fine ;-)

jp passama
http://perso.wanadoo.fr/passama/

Re:Copying fields/records from query to table


try TBatchMove component

In article <34DD03C5....@clara.net>, d...@clara.net says...

Quote
> D2.0, C/S, W95
> Is there an easier way to copy fields from a query to a table than (eg):
> dmData.taCustomerCustName.AsString:=dmData.quCustomerCustName.AsString;
> This does work but is very cumbersome when there are many fields in the
> table.
> I'm sure there must be a simple way to copy all fields in one go.
> All suggestions welcome. TIA
> David Carle.

Other Threads