473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VB.net Form to Read and Update XML

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

Sep 13 '06 #1
0 4267

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
13
by: Ioannis Vranos | last post by:
Why in this code the form *does not refresh* when it gets the focus/after some time? #using <mscorlib.dll> #using <system.windows.forms.dll> #using <system.dll> #using <system.drawing.dll>
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
4
by: MicroMoth | last post by:
Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
8
by: chromis | last post by:
Hi, I'm writing a contacts section for a cms on a website, I've decided to write the section in OO code. So far I have my Contacts object and a page structure I would use for a procedural site. ...
1
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.