tags:

views:

584

answers:

3

Can TClientDataSet Nested (one-to-many) DataSets be created at runtime? Is there any code that shows how to do this?

Thanks,

Bill

A: 

What do you mean? A client dataset is a single table. But you can create a field which contains another clientdataset (which must be extracted to be used).

Gamecat
+1  A: 

Creating a one-to-many relationship isn't all that difficult. It can be done at design-time or at runtime:

  1. Create the master dataset.
  2. Make sure it contains a primary key field.
  3. Create the detail dataset. Make sure it contains a foreign key field.
  4. Link the detail dataset to the master dataset as follows:
  5. Set the MasterSource property to the master dataset.
  6. Set the MasterField property to the primary key field of the master dataset.
  7. Set the IndexFieldNames property to the foreign key of the detail dataset.
  8. Done!
Mason Wheeler
+3  A: 

Nesting DataSets in ClientDataSets by Cary Jensen should answer your question. Also look for other articles on this site by Cary for more information on ClientDataSets.

Jozz