Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Fill Data of Parents and multi levels of Child tables only

Fill Data of Parents and multi levels of Child tables only

Scheduled Pinned Locked Moved Visual Basic
tutorialhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EngrImad
    wrote on last edited by
    #1

    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...

    L E 2 Replies Last reply
    0
    • E EngrImad

      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...

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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 TEXT

      The 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.

      1 Reply Last reply
      0
      • E EngrImad

        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...

        E Offline
        E Offline
        evry1falls
        wrote on last edited by
        #3

        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[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups