0

I have

ClientDataSet1 > DataSetProvider1 > SqlDataSet1> sql = select * from customer

i add all fields at design time than i copy the ClientDataSet1 rename it to ClientDataSet2 On DataModule create event i clone the cursor

ClientDataset2.CloneCursor(ClientDataset1, True);

so the cloned dataset has now all persistence fields defined in cds1 according to the answer in this question i attempted to add extra field InternalCalc/LookupField to the cloned dataset at design time but error occurred during the execution "Field not Found"

My question what is the correct way to add extra field that doesn't exist in the master dataset nor in the database to a cloned TClientDataSet.

thank's ...

Community
  • 1
  • 1
S.FATEH
  • 451
  • 8
  • 16
  • _i attempted to add extra field InternalCalc/LookupField to the cloned dataset at design time_ - but at designtime it's not yet cloned; you clone it at runtime. – Ondrej Kelle Dec 27 '13 at 15:09
  • yes, at design time and i remove pfInWhere/pfInUpdate from the provider flags whene i open cds2 error occur – S.FATEH Dec 27 '13 at 15:14
  • 1
    To add fields to a cloned dataset you need to clone it *first* because cloning clears any current field definitions. This means you have to add your calculated and lookup fields at runtime, after cloning. – Ondrej Kelle Dec 27 '13 at 15:19
  • ok thank's TOndrej could you provide more explanation about _cloning clears any current field definitions_ i didn't get it yet i could iterate Fields defined at design time without any problem also bind them with data aware components – S.FATEH Dec 27 '13 at 15:23
  • 1
    Cloning a dataset takes over the field definitions from the source dataset. The fields you have defined for the target dataset before cloning get discarded. – Ondrej Kelle Dec 27 '13 at 15:31
  • TOndrej that make sense thank's... – S.FATEH Dec 27 '13 at 15:41

0 Answers0