469,609 Members | 2,217 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Read from xml file stored in a SQL database table’s field.

Hello all I am a beginner .Net programmer so please forgive my ignorance.

In brief, I am trying to read from xml file stored in a SQL database table’s

This is what I used to create the table:
Description nvarchar(50) NOT NULL,
DocumentStore xml NOT NULL,

This is what I used to insert my XML document into a SQL database table’s
INSERT INTO Document (Description, DocumentStore)
VALUES('Bruce''s poem',
N'<?xml version="1.0" ?>
<Document Name="Poem">
<Text>The cat/is flat.</Text>
This is my XML document’s contents.
<?xml version="1.0"?>
<Document Name="CRCPermission">
<PermissionName>Security Tool Bar</PermissionName>
<PermissionName>Employee Tool Bar</PermissionName>
<PermissionName>Case Find Tool Bar</PermissionName>
<PermissionName>Case Look Up Tool Bar</PermissionName>
<PermissionName>Allegations Tool Bar</PermissionName>
<PermissionName>Subjects Tool Bar</PermissionName>
<PermissionName>Hiring Authority Tool Bar</PermissionName>

This is my code I use to display my XML document into my form’s list view
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports System.Xml
Imports System.Xml.XPath
Imports System.Data.SqlTypes
Imports System.Configuration
Imports Microsoft.Data.SqlXml
Imports System.Data.OleDb

Public Class Form1
Dim WithEvents xmldoc2 As Xml.XmlDataDocument ' "MAKE GLOBAL"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim investigationsinfo As New SqlDataAdapter("select TOP 1
DocumentStore from Document FOR XML AUTO, TYPE", SqlConnection1)
Dim ds As DataSet
ds = New DataSet()
'filling the dataset
investigationsinfo.Fill(ds, "Document")
Dim InvestDataSet As XmlDataDocument
InvestDataSet = New XmlDataDocument(ds)
'I put this one in to see if it had a different result
Dim root As XmlNode = InvestDataSet.DocumentElement
Dim elemList1 As XmlNodeList
Dim elemList2 As XmlNodeList
Dim Employee As XmlNode
Dim Child As XmlNode
Dim NewItem As Boolean
Dim ict As Integer
Dim Lv
'I want either one to work
elemList2 = root.SelectNodes("descendant::ToolBars/Permission")
elemList1 = InvestDataSet.GetElementsByTagName("ToolBars/Permission")
For Each Employee In elemList1
' Use the Text property of each node
' to write the listview
NewItem = True
ict = 0
For Each Child In Employee.ChildNodes
If NewItem Then
lv = ListView1.Items.Add(Child.InnerText)
NewItem = False
ict = ict + 1
lv.SubItems(ict) = _
End If
End Sub
End Class

I am using Microsoft Visual Basic 2005 and SQL Server 2005:
Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600

This code above only returns some value to the variable when I reference
elemList2 = root.SelectNodes("descendant::Document")
elemList1 = InvestDataSet.GetElementsByTagName("Document")

Help Please

thanks for your help...
Sep 17 '06 #1
0 3239

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sandi | last post: by
3 posts views Thread by Karen Grube | last post: by
3 posts views Thread by Sandi | last post: by
3 posts views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.