hello guys,
here's what I have done:
In my Command Button to execute the Process:
PopulateTables()
GetList_First()
MessageBox.Show("XML File Successfully Generated !", "XML Creation", MessageBoxButtons.OK, MessageBoxIcon.Information)
In the PopulateTables() Function:
Public Sub PopulateTables()
Dim strSELECT As String = "SELECT * FROM tblstudents "
Dim DReader As New DataClassReader
DReader.strSELECTSQL = strSELECT
DReader.ReadData()
dtgView.Rows.Clear()
Dim a As Integer = 0
Do While DReader.PinoyLDataReader.Read
dtgView.Rows.Add()
With DReader.PinoyLDataReader
dtgView.Item(0, a).Value = .Item("idtblstudents")
dtgView.Item(1, a).Value = .Item("studentID")
dtgView.Item(2, a).Value = .Item("s_sy")
dtgView.Item(3, a).Value = .Item("fullname")
dtgView.Item(4, a).Value = .Item("fname")
dtgView.Item(5, a).Value = .Item("lname")
dtgView.Item(6, a).Value = .Item("mname")
dtgView.Item(7, a).Value = .Item("bday")
dtgView.Item(8, a).Value = .Item("gender")
dtgView.Item(9, a).Value = .Item("address")
dtgView.Item(10, a).Value = .Item("s_contctno")
dtgView.Item(11, a).Value = .Item("parent_guardian")
dtgView.Item(12, a).Value = .Item("p_contctno")
dtgView.Item(13, a).Value = .Item("s_year_section")
dtgView.Item(14, a).Value = .Item("remarks")
End With
a = a + 1
Loop
DReader.PinoyLDataReader.Close()
End Sub
In the GetList_First() Function:
Public Sub GetList_First()
If dtgView.Rows.Count > 0 Then
Dim i As Integer = 0
Dim rCnt As Integer = dtgView.Rows.Count
For i = 0 To rCnt - 1
With dtgView
Dim writer As New XmlTextWriter("Student List.xml", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("Student")
Create_XML(.Item(0, i).Value, _
.Item(1, i).Value, _
.Item(2, i).Value, _
.Item(3, i).Value, _
.Item(7, i).Value, _
.Item(8, i).Value, _
.Item(9, i).Value, _
.Item(10, i).Value, _
.Item(11, i).Value, _
.Item(13, i).Value, _
writer)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
End With
Next
End If
End Sub
In the Create_XML() Function :
Private Sub Create_XML(ByVal idtblstudents As String, _
ByVal studentID As String, _
ByVal s_sy As String, _
ByVal fullname As String, _
ByVal bday As String, _
ByVal gender As String, _
ByVal address As String, _
ByVal s_contctno As String, _
ByVal parent_guardian As String, _
ByVal s_year_section As String, _
ByVal writer As XmlTextWriter)
writer.WriteStartElement("Students")
writer.WriteStartElement("idtblstudents")
writer.WriteString(idtblstudents)
writer.WriteEndElement()
writer.WriteStartElement("studentID")
writer.WriteString(studentID)
writer.WriteEndElement()
writer.WriteStartElement("s_sy")
writer.WriteString(s_sy)
writer.WriteEndElement()
writer.WriteStartElement("fullname")
writer.WriteString(fullname)
writer.WriteEndElement()
writer.WriteStartElement("bday")
writer.WriteString(bday)
writer.WriteEndElement()
writer.WriteStartElement("gender")
writer.WriteString(gender)
writer.WriteEndElement()
writer.WriteStartElement("address")
writer.WriteString(address)
writer.WriteEndElement()
writer.WriteStartElement("s_contctno")
writer.WriteString(s_contctno)
writer.WriteEndElement()
writer.WriteStartElement("parent_guardian")
writer.WriteString(parent_guardian)
writer.WriteEndElement()
writer.WriteStartElement("s_year_section")
writer.WriteString(s_year_section)
writer.WriteEndElement()
writer.WriteEndElement()
End Sub
It performs correctly, but the problem is it only gets the last record/data in the Datagrid...
Please help...
Thanks in advance..... ;)