简体   繁体   中英

simple way to copy recordset from fdquery to fdquery

Using fireDac, is there a simpler way to copy FDQuery to FDQuery?

the current hardcoded solution is to map each field in code to eache other field in code and post and edit and such.

var
FDQueryThis,FDQueryOther:TFDQuery;
begin
  FDQueryThis.active:=true;
  FDQueryOther.active:=true;
  FDQueryThisNamelyField.AsInteger := FDQueryThis.NamelyField.AsInteger;
// some more fields
FDQueryThis.post;
end;

Is there a tool or a function that provide this service? I did see CopyRecord as a member of TFDQuery, howver how to create a record For TFDQuery?

I'd just use CloneCursor method,

FDQueryThis.CloneCursor(FDQueryOther, True, False);

Here You've got full description

However keep in mind the physical data stays the same. if you want to copy the data to a different location use .Data property:

FDQueryThis.Data := FDQueryOther.Data;

Best regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM