Results 1 to 6 of 6

Thread: Parent - Child ...

  1. #1

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437

    Parent - Child ...

    I have a situation where I have data in my database in Windows Explorer style. Where there can be n-number of Parent-Child relationships. A Parent can have 5 childs, out of those five, 2 may have more childs and so on ... How do I retrieve this data in ...

    1. Either direct in XML format ... in that tree style ... so that I can easily parse through the xml and load in treeview.

    2. Or if that is not possible, then normal style, but what logic should I use to load this data in a TreeView.

    I am struggling with logic here ...

  2. #2

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437

  3. #3
    Lively Member TLord's Avatar
    Join Date
    Jun 2004
    Posts
    95
    I would liek to help, but give mre information...
    what type of database? do you mean it is it on a server or in XML files? ...
    Do you think my life is easy?
    Do you think it's good to win?
    do you think it's nice to kill?
    Do you think learning is a must?
    Do you think computers are nothing?
    Do you think this post is stupid?
    Do ypu think we're really humen?

    DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !

  4. #4

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437
    Its a SQL Server database. There is a table. Where you can create folders/Child folders. ( its the information ) A child folder will have a parent. Now I wanna display all this information in a treeview ... how ?

  5. #5
    Lively Member TLord's Avatar
    Join Date
    Jun 2004
    Posts
    95
    Sorry, but I don't get you exactly, but a series of loops may do the job in a far try.
    Do you think my life is easy?
    Do you think it's good to win?
    do you think it's nice to kill?
    Do you think learning is a must?
    Do you think computers are nothing?
    Do you think this post is stupid?
    Do ypu think we're really humen?

    DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !

  6. #6
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    this, mate?
    VB Code:
    1. Dim cn As New SqlConnection()
    2.    Dim da As New SqlDataAdapter()
    3.    Dim ds As New DataSet()
    4.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.       cn.ConnectionString = "user id=sa;password=password;initial catalog=pubs"
    6.       cn.Open()
    7.  
    8.       ds.Tables.Add(New DataTable("titles"))
    9.       ds.Tables.Add(New DataTable("publishers"))
    10.  
    11.       da.SelectCommand = New SqlCommand("select * from titles", cn)
    12.       da.Fill(ds.Tables("titles"))
    13.       da.SelectCommand = New SqlCommand("select * from publishers", cn)
    14.       da.Fill(ds.Tables("publishers"))
    15.  
    16.       out()
    17.    End Sub
    18.  
    19.    Sub out()
    20.       Dim r1 As DataRow
    21.       Dim i As Integer = 0
    22.       For Each r1 In ds.Tables("titles").Rows
    23.          TreeView1.Nodes.Add(r1(0).ToString)
    24.          TreeView1.Nodes(i).Nodes.Add(r1(1).ToString)
    25.          TreeView1.Nodes(i).Nodes.Add(r1(2).ToString)
    26.          Dim s As String = r1(3).ToString
    27.          TreeView1.Nodes(i).Nodes.Add(s) ' publisher
    28.          TreeView1.Nodes(i).Nodes.Add(r1(4).ToString)
    29.          TreeView1.Nodes(i).Nodes.Add(r1(5).ToString)
    30.          TreeView1.Nodes(i).Nodes.Add(r1(6).ToString)
    31.          TreeView1.Nodes(i).Nodes.Add(r1(7).ToString)
    32.          TreeView1.Nodes(i).Nodes.Add(r1(8).ToString)
    33.          TreeView1.Nodes(i).Nodes.Add(r1(9).ToString)
    34.  
    35.          ds.Tables("publishers").Clear()
    36.          da.SelectCommand = New SqlCommand("select * from publishers where pub_id='" & s & "'", cn)
    37.          da.Fill(ds.Tables("publishers"))
    38.          Dim r2 As DataRow
    39.          For Each r2 In ds.Tables("publishers").Rows
    40.             TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(1).ToString)
    41.             TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(2).ToString)
    42.             TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(3).ToString)
    43.             TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(4).ToString)
    44.          Next
    45.  
    46.          i += 1
    47.       Next
    48.    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width