It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

How to store/save treeview information from vb to oracle

Moderator: dafunkymunky

How to store/save treeview information from vb to oracle

Postby allgodscreation on Sat Oct 18, 2008 5:19 pm

The outcome of the codes below would be the display of a treeview based on an xml file...My question would be : How do i store/save the nodes information OR treeview nodes information, into the oracle database?The treeview information should be stored in 1 database together with 3 tables named xml1, xml2 and userxml....Can you plz help me>???PLZZ?thanks a lot...Below are the codes of the program...


CODINGS
---------------

Imports System.Xml

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As Sys[code]tem.EventArgs) Handles MyBase.Load
' Initialize the controls and the form.
Label1.Text = "File Path"
Label1.SetBounds(8, 8, 50, 20)
TextBox1.Text = "C:\Documents and Settings\WingHoe\My Documents\My Received Files\xml1.xml"
TextBox1.SetBounds(64, 8, 256, 20)
Button1.Text = "Populate the TreeView with XML"
Button1.SetBounds(8, 40, 200, 20)
Me.Text = "TreeView control from XML"
Me.Width = 336
Me.Height = 368
TreeView1.SetBounds(8, 72, 312, 264)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim dom As New XmlDocument()
dom.Load(TextBox1.Text)

TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
Dim tNode As New TreeNode()
tNode = TreeView1.Nodes(0)

AddNode(dom.DocumentElement, tNode)
TreeView1.ExpandAll()

Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

End Sub

Private Sub AddNode(ByRef inXmlNode As XmlNode, ByRef inTreeNode As TreeNode)
Dim xNode, xNode1 As XmlNode
Dim tNode, tNode1, tNode2 As TreeNode
Dim nodeList As XmlNodeList
Dim i As Integer

If inXmlNode.HasChildNodes() Then
nodeList = inXmlNode.ChildNodes
For i = 0 To nodeList.Count - 1
xNode1 = inXmlNode
tNode1 = inTreeNode
xNode = inXmlNode.ChildNodes(i)
tNode2 = New TreeNode(xNode.Name)
tNode2.ImageIndex = 2
inTreeNode.Nodes.Add(tNode2)
tNode = inTreeNode.Nodes(i)
If xNode.Attributes.Count > 0 Then
addattribute(xNode, tNode1)
End If

AddNode(xNode, tNode)
Next
'Else
'inTreeNode.Text = (inXmlNode.OuterXml).Trim
End If
End Sub

Private Sub addattribute(ByRef inXmlNode As XmlNode, ByRef inTreeNode As TreeNode)
Dim i As Integer
Dim tnode, tnode1 As TreeNode
For i = 0 To inXmlNode.Attributes.Count - 1
tnode1 = New TreeNode(inXmlNode.Attributes(i).Name.ToString())
tnode1.ImageIndex = 0
inTreeNode.LastNode.Nodes.Add(tnode1)
tnode = inTreeNode.LastNode.LastNode
tnode1 = New TreeNode(inXmlNode.Attributes(i).Value.ToString())
tnode1.ImageIndex = 1
tnode.Nodes.Add(tnode1)
Next
End Sub

End Class



XML1
--------------
<?xml version="1.0" encoding="UTF-8"?>

<pets>

<pet name="Maximillian" type="pot bellied pig" age="3">
<friend name = "Augustus"/>
<friend name = "Nigel"/>
</pet>


<pet name="Augustus" type="goat" age="2">
<friend name = "Maximillian"/>
</pet>

<pet name="Nigel" type="chipmunk" age="2">
<friend name = "Maximillian"/>
</pet>
</pets>
allgodscreation
 
Posts: 0
Joined: Sat Oct 18, 2008 4:21 pm

Who is online

Users browsing this forum: psbot [Picsearch] and 7 guests