|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADO and parent/child/grandchildrenUsing 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 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. Show quote "Jeremiah Harbottle" <nik***@REMOVETHIS.nildram.REMOVETHIS.co.uk> wrote in message news:xsadnU1F5uA-EFjenZ2dnUVZ8t2dnZ2d@pipex.net... > 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 > > > > |
|||||||||||||||||||||||