Fill Data of Parents and multi levels of Child tables only
-
I would like to know how to fill the Parent table and multi different levels of child tables with data, mean the child tables will be filled with data relate to that Parent table only.. Example: Level 1 : GRANDFATHER table - Can be fill using Data Adapter Like: (DataAdapter.Fill(DataSet.DataTable,GRANDFATHER-ID) - {(GRANDFATHER-ID is Primary Key)} here i select specific record and fill and everything good Level 2 : Father table - Can be fill using Data Adapter Like:(DataAdapter.Fill(DataSet.DataTable, MYGRANDFATHER-ID) - {(MYGRANDFATHER-ID is Foreign Key)} mean here i can fill level 2 of child table because it is link to one record only from Parent table so I fill all fathers and one Grandfather, and still everything is good Level 3 : Kids table - Here we face problem!! , How to Fill Data Adapter using multi Fathers ID?? mean i want to fill all kids under multi fathers related to that Parent table of one GRANDFATHER only.. I don not like to fill all Kids Data under all Fathers and All Grandfathers, hopefully i found solution and clear what I mean...
-
I would like to know how to fill the Parent table and multi different levels of child tables with data, mean the child tables will be filled with data relate to that Parent table only.. Example: Level 1 : GRANDFATHER table - Can be fill using Data Adapter Like: (DataAdapter.Fill(DataSet.DataTable,GRANDFATHER-ID) - {(GRANDFATHER-ID is Primary Key)} here i select specific record and fill and everything good Level 2 : Father table - Can be fill using Data Adapter Like:(DataAdapter.Fill(DataSet.DataTable, MYGRANDFATHER-ID) - {(MYGRANDFATHER-ID is Foreign Key)} mean here i can fill level 2 of child table because it is link to one record only from Parent table so I fill all fathers and one Grandfather, and still everything is good Level 3 : Kids table - Here we face problem!! , How to Fill Data Adapter using multi Fathers ID?? mean i want to fill all kids under multi fathers related to that Parent table of one GRANDFATHER only.. I don not like to fill all Kids Data under all Fathers and All Grandfathers, hopefully i found solution and clear what I mean...
Kids don't have multiple fathers; there can be only one. The table-design is wrong, you don't want a table per generation. More simple, like;
SomeAutoId LONGINT,
ParentId LONGINT,
Name TEXTThe ParentId should point to the parent of the this record. The Id of this record in its own turn will be referenced from any children it has. E.g.; you have a father (called father for simplicity) and two children (child1 and child2). The data would look like below;
SomeAutoId ParentId Name
1 NULL Father -- Here NULL is used as a parent,
-- because we don't know about your fathers' father
2 1 EngrImad -- Here we point to record 1 in ParentId, as that is your father
3 2 Child1 -- ParentId pointing to the record with your name
23 2 Child2 -- Ditto as above; points to the record with SomeAutoId 2.
24 13 Chris -- not your child :)
1654 23 Grandchild1 -- first child of your second child.This way you can have an entire tree in a database, extend it easy without creating tables on the fly for generations. That also makes populating the visual tree easier; you query your table for the root-nodes (parents without a ParentId). If that node opens, fetch the children of that node.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
I would like to know how to fill the Parent table and multi different levels of child tables with data, mean the child tables will be filled with data relate to that Parent table only.. Example: Level 1 : GRANDFATHER table - Can be fill using Data Adapter Like: (DataAdapter.Fill(DataSet.DataTable,GRANDFATHER-ID) - {(GRANDFATHER-ID is Primary Key)} here i select specific record and fill and everything good Level 2 : Father table - Can be fill using Data Adapter Like:(DataAdapter.Fill(DataSet.DataTable, MYGRANDFATHER-ID) - {(MYGRANDFATHER-ID is Foreign Key)} mean here i can fill level 2 of child table because it is link to one record only from Parent table so I fill all fathers and one Grandfather, and still everything is good Level 3 : Kids table - Here we face problem!! , How to Fill Data Adapter using multi Fathers ID?? mean i want to fill all kids under multi fathers related to that Parent table of one GRANDFATHER only.. I don not like to fill all Kids Data under all Fathers and All Grandfathers, hopefully i found solution and clear what I mean...
I suggest you dig more in Hierarchical term. This is an example of visual basic .net winform project that uses MS-Access 2007 database and populate a TreeView control with all Data as [Parent->Child->GrandChild]. VB.NET Access 2007 Hierarchical TreeView[^]