?
Solved

Bill Of Material

Posted on 2005-03-14
13
Medium Priority
?
1,658 Views
Last Modified: 2011-09-20
I am looking for some example code to explode a multi level Bill Of Material.

My Table structure is as Follows:

ParentID
ChildID
Level

An Individual BOM might have several levels.

I need one that will work with either Access or SQL Server.

Any examples of a recursive explosion would be great.

Thanks in advance

Andy
0
Comment
Question by:andytauber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 

Author Comment

by:andytauber
ID: 13540631
I shoud add that i'm looking for a asp.net vb example.

Thanks
0
 
LVL 33

Expert Comment

by:raterus
ID: 13541371
how would you like to display this to the user?
0
 

Author Comment

by:andytauber
ID: 13547423
I want ot put it in a treeview
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:raterus
ID: 13547674
is this the microsoft treeview control?
0
 

Author Comment

by:andytauber
ID: 13548611
I'm using componentart. I just need to get the structure into a dataset.
0
 
LVL 33

Expert Comment

by:raterus
ID: 13548791
What exactly are you trying to do, I'm confused

Query DB and display Bill of Sale in Treeview
or
Traverse Treeview and insert into database?
0
 

Author Comment

by:andytauber
ID: 13548879
I want to display the bill in a treeview

I am looking for the code to explode it into a dataset.
0
 
LVL 33

Expert Comment

by:raterus
ID: 13548981
a dataset is still a flat-file representation, you can fill it like any other sql query.  When you fill the treeview is when you'll use recursion.  I can help you with that part, but I'll need to know how you actually fill the treeview. (If it has nodes, and you can add one node to another in code, we're set)
0
 

Author Comment

by:andytauber
ID: 13549503
Yes each node represents an item. The nodes need to reflect the relationship. I.E.

Parent
   Child1
   Child 2
      Child 3
      Child 4
         Child 5
   Child 6
etc....
0
 
LVL 33

Expert Comment

by:raterus
ID: 13555230
Is there going to be a root node in the treeview, or could there be many top-level nodes?  I'm looking at a project now where I'm doing the exact same thing, only there isn't a root node, per se.
0
 

Author Comment

by:andytauber
ID: 13558645
There are many top levels

+ Parent1
+ Parent 2
+ Parent 3
0
 
LVL 33

Accepted Solution

by:
raterus earned 2000 total points
ID: 13558832
This is how I've done the same thing in a program of mine, I've tried to comment it... "GetNodes()" is your starting Sub, you'll have to adapt it for your treeview controls, but if it works like microsofts, this shouldn't be a problem.

    Private Sub GetNodes()
      'Do any code to fill "dt", a datatable with valid information (childID, parentID essential)
      Dim dt as DataTable = FillDataTable()
      Dim rootParentID as string = "0"      'this is the parentID of your root nodes

      'tv is my treeview
        tv.Nodes.Clear()

        Dim drs As DataRow() = dt.Select("[parentID] = '" & rootParentID & "'")
        For Each dr As DataRow In drs
            Dim node As TreeNode = New TreeNode
            node.Text = CStr(dr("ChildID"))
            FillNodes(dt, node.NodeData, node)
            tv.Nodes.Add(node)
        Next
    End Sub

    Private Sub FillNodes(ByVal dt As DataTable, ByVal parentID As String, ByRef node As TreeNode)
        Dim drs As DataRow() = dt.Select("[parentID] = '" & parentID & "'")
        For Each dr As DataRow In drs
            Dim newNode As TreeNode = New TreeNode
            newNode.Text = CStr(dr("ChildID"))
            FillNodes(dt, newNode.NodeData, newNode)
            node.Nodes.Add(newNode)
        Next
    End Sub
0
 

Author Comment

by:andytauber
ID: 13559744
Thanks This works great!!!!
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question