4

I have a simple code which creates a copy a dataset and all of it's detail datasets at runtime:

    DestDataSet.FieldDefs.Assign(SourceDataSet.FieldDefs);
    SourceDataSet.GetDetailDataSets(DetailList);
    for i := 0 to DetailList.Count - 1 do
    begin
      with DestDataSet.FieldDefs.AddFieldDef do
      begin
        Name := TDataSet(DetailList[i]).Name;
        DataType := ftDataSet;
      end;
      DetailCDSs.Add(NestedCDS);
    end;
    DestDataSet.CreateDataSet;

CreateDataSet raises an EDBClient exception with the message "Invalid Field Type". Can anyone tell me what's wrong?

iMan Biglari
  • 4,674
  • 1
  • 38
  • 83
  • 3
    If you create a dataset with fielddef having datatype ftdataset, you need to declare the child definition (childdefs), all the way until the declaration is not ftdataset. – Hendra Aug 29 '12 at 13:06

1 Answers1

1

If you create a dataset with FieldDef having ftDataSet fields, you need to declare the child definition before creating the dataset.

iMan Biglari
  • 4,674
  • 1
  • 38
  • 83