I have a form that I'm trying to get to work in VB.net (Standard). I
have a DataGrid and Two Buttons (One for Loading an XML file and
another for Updating the file with the changes I make to the records in
the DataGrid).
(This is a lab I'm working on in a training book - written by Mr.
Gunderloy for MS Exam 70-310).
I pasted the following code with numerous errors, however, when I was
using a trial VB.net copy I was able to get it to work flawlessly.
I've tried several things:
The training book says (after designing the form) to double-click one
of the buttons to open the form's module, then add the following code
at the top (do they really mean the TOP of the module? above the VB
generated code?):
Imports System.Data
Imports System.Xml
_______________________________________
then the instructions call for placing the below code to handle the
events:
Public Class StepByStep2_4
Dim xdd As XmlDataDocument
Dim ds As DataSet
Private Sub btnLoadXml_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnLoadXml.Click
Dim xtr As XmlTextReader = _
New XmlTextReader("C:\Documents and Settings\dcampbe\My
Documents\Visual Studio 2005\Projects\310C02\310C02\Books.xml")
xdd = New XmlDataDocument()
ds = xdd.DataSet()
ds.ReadXmlSchema(xtr)
xtr.Close()
xtr = New XmlTextReader("C:\Documents and Settings\dcampbe\My
Documents\Visual Studio 2005\Projects\310C02\310C02\Books.xml")
xtr.WhitespaceHandling = WhitespaceHandling.None
xdd.Load(xtr)
dgXML.DataSource = ds
dgXML.DataMember = "Book"
xtr.Close()
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim xtw As XmlTextWriter = New XmlTextWriter("C:\Documents and
Settings\dcampbe\My Documents\Visual Studio
2005\Projects\310C02\310C02\Books.xml", System.Text.Encoding.UTF8)
xtw.Formatting = Formatting.Indented
xdd.WriteTo(xtw)
'Clean up
xtw.Close()
MessageBox.Show("The XML file has been successfully updated !")
End Sub
End Class
__________________________________________________ _
Any advice on how to get this to work again, or a better way??
THANKS ALL!
Dav