|
-
Jul 21st, 2004, 01:42 PM
#1
Thread Starter
Hyperactive Member
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 ...
-
Jul 21st, 2004, 04:30 PM
#2
Thread Starter
Hyperactive Member
-
Jul 21st, 2004, 04:52 PM
#3
Lively Member
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? ? ? ! ! !
-
Jul 21st, 2004, 04:54 PM
#4
Thread Starter
Hyperactive Member
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 ?
-
Jul 21st, 2004, 04:58 PM
#5
Lively Member
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? ? ? ! ! !
-
Jul 21st, 2004, 10:20 PM
#6
Fanatic Member
this, mate?
VB Code:
Dim cn As New SqlConnection()
Dim da As New SqlDataAdapter()
Dim ds As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.ConnectionString = "user id=sa;password=password;initial catalog=pubs"
cn.Open()
ds.Tables.Add(New DataTable("titles"))
ds.Tables.Add(New DataTable("publishers"))
da.SelectCommand = New SqlCommand("select * from titles", cn)
da.Fill(ds.Tables("titles"))
da.SelectCommand = New SqlCommand("select * from publishers", cn)
da.Fill(ds.Tables("publishers"))
out()
End Sub
Sub out()
Dim r1 As DataRow
Dim i As Integer = 0
For Each r1 In ds.Tables("titles").Rows
TreeView1.Nodes.Add(r1(0).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(1).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(2).ToString)
Dim s As String = r1(3).ToString
TreeView1.Nodes(i).Nodes.Add(s) ' publisher
TreeView1.Nodes(i).Nodes.Add(r1(4).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(5).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(6).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(7).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(8).ToString)
TreeView1.Nodes(i).Nodes.Add(r1(9).ToString)
ds.Tables("publishers").Clear()
da.SelectCommand = New SqlCommand("select * from publishers where pub_id='" & s & "'", cn)
da.Fill(ds.Tables("publishers"))
Dim r2 As DataRow
For Each r2 In ds.Tables("publishers").Rows
TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(1).ToString)
TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(2).ToString)
TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(3).ToString)
TreeView1.Nodes(i).Nodes(2).Nodes.Add(r2(4).ToString)
Next
i += 1
Next
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|