ADO and parent/child/grandchildren

J

Jeremiah Harbottle

Hi,

Using VC to write a small app that displays data extracted from a database
into a typed DataSet. That all works fine.

I have three tables - Parent, Child, and then each record in the Child table
also has children.

I want three grids - one for each table:

A. Parent (ParentID is key)
B. Child (ChildID is key, FK to ParentID)
C. GrandChild (GCID is key, FK to ChildID)

So, when the user selects a parent, the child grid shows the correct
records. Subsequently, selecting a child row should show the grandchildren
records for that row.

I've set up all the datarelations correctly and used the DataSource,
DataMember on the grid.

GridA - DataSource = myDataset
DataMember = ParentTable
GridB - DataSource = myDataSet
DataMember = ParentChildRelation
GridB - Datasource = myDataSet
DataMember = myChildGCRelation

Selecting a record in A causes B to only shows those with the correct FK.
Brilliant. Adding a new record fills in the FK column with the correct
value. Splendid!

However, it doesn't work with the Child/Grandchild tables? The GrandChild
grid always shows the same record...

Can .Net handle this? Am I doing something wrong?

Regards,
JH
 
R

Robbe Morris [C# MVP]

Why do you have a grandchild relationship?

You should just have a parent and a child.

Each child can be a parent and so and
son on.

You would use recursion to traverse
the entire hierarchy of your DataSet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top