This code creates XML File
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
connetionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
connection = New SqlConnection(connetionString)
sql = "select * from Acc"
Try
If IO.File.Exists("Testimage.xml") = False Then
connection.Open()
adapter = New SqlDataAdapter(sql, connection)
adapter.Fill(ds)
connection.Close()
ds.WriteXml("Testimage.xml")
MsgBox("File Created")
Else
MsgBox("File Already Exists")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
This Code read file and sends it's contents to textbox(es)
Dim xmlFile As XmlReader
xmlFile = XmlReader.Create("Testimage.xml", New XmlReaderSettings())
Dim ds As New DataSet
While ds.ReadXml(xmlFile)
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
TextBox1.Text = (ds.Tables(0).Rows(i).Item(1))
TextBox2.Text = (ds.Tables(0).Rows(i).Item(2))
TextBox3.Text = (ds.Tables(0).Rows(i).Item(3))
TextBox4.Text = (ds.Tables(0).Rows(i).Item(4))
TextBox5.Text = (ds.Tables(0).Rows(i).Item(5))
TextBox6.Text = (ds.Tables(0).Rows(i).Item(6))
TextBox7.Text = (ds.Tables(0).Rows(i).Item(7))
TextBox8.Text = (ds.Tables(0).Rows(i).Item(8))
TextBox9.Text = (ds.Tables(0).Rows(i).Item(9))
Next
End While
End Sub
This code navigate records ...and needs help
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim nav As XPathNavigator
Dim docNav As XPathDocument
docNav = New XPathDocument("Testimage.xml")
nav = docNav.CreateNavigator
nav.MoveToRoot()
nav.MoveToNext()
Do
Dim i As Integer
i = +1
Loop While nav.MoveToNext
'Pause.
Console.ReadLine()
End Sub