473,320 Members | 1,977 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,320 software developers and data experts.

Dataset (ds.writexml) written to xml file incorrectly

Hello all.
I'm reading the data from an XML file similiar to below, using the
code below. When the
file is edited in the datagridview and then re-written, it doesn't
write the xml
file as it was originally written.

So what am I doing wrong? My code and samples are below. Any help
would be greatly appreciated!!

VISUAL STUDIO 2005
..NET 2.0 FRAMEWORK, VB.NET CODE

Declare a bindings source, a dataset, a binding navigator, and set up
a datagridview where the
data is displayed & edited

'now associate them

bndgSrc1.DataSource = ds
dgvConfig.DataSource = bndgSrc1
binNav1.BindingSource = bndgSrc1

'Now read the xml file into the dataset &
ds.ReadXml(My.Settings.configFile)
bndgSrc1.DataMember = "pnum"
bndgSrc1.ResetBindings(False)

I save the edited info as below:

dgvConfig.EndEdit()
bndgSrc1.EndEdit()
If ds.HasChanges Then
ds.AcceptChanges()
ds.WriteXml(My.Settings.configFile, XmlWriteMode.WriteSchema)
End If
bndgSrc1.ResetBindings(False)

!<ORIGINAL XML FILE SAMPLE BELOW>

<?xml version="1.0" standalone="yes"?>
<config>
<workstations>
<ws>pcnamexxx</ws>
<ws>pcnamexxx</ws>
</workstations>
<patches>
<pnum>1837</pnum>
</patches>
<users>
<uid>user3</uid>
<uid>user4</uid>
</users>
<ad>
<ou>OU=firstlevel,OU=secondlevel,DC=GOOGLE,DC=CO M</ou>
<ou>OU=anotherou,OU=yetanother,DC=GOOGLE,DC=COM</ou>
</ad>
</config>

If I delete all the records, I just get the "<patches /remnant left
behind:

!<SAVED (ALL PATCHES RECORDS DELETED) XML FILE SAMPLE BELOW>

<?xml version="1.0" standalone="yes"?>
<config>
<workstations>
<ws>pcnamexxx</ws>
<ws>pcnamexxx</ws>
</workstations>
<patches />
<users>
<uid>user3</uid>
<uid>user4</uid>
</users>
<ad>
<ou>OU=firstlevel,OU=secondlevel,DC=GOOGLE,DC=CO M</ou>
<ou>OU=anotherou,OU=yetanother,DC=GOOGLE,DC=COM</ou>
</ad>
</config>

If I enter a new record, it doesn't nest it within the parent, as
below:

!<SAVED (NEW PATCHES RECORD INSERTED) XML FILE SAMPLE BELOW>

<?xml version="1.0" standalone="yes"?>
<config>
<workstations>
<ws>pcnamexxx</ws>
<ws>pcnamexxx</ws>
</workstations>
<patches>
<pnum>1837</pnum>
</patches>
<pnum>1838</pnum>
<users>
<uid>user3</uid>
<uid>user4</uid>
</users>
<ad>
<ou>OU=firstlevel,OU=secondlevel,DC=GOOGLE,DC=CO M</ou>
<ou>OU=anotherou,OU=yetanother,DC=GOOGLE,DC=COM</ou>
</ad>
</config>

Mar 12 '07 #1
0 2506

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

Similar topics

1
by: Rahul Agarwal | last post by:
Hi I am trying to write data back to the client using dataset.WriteXML and I have set the Thread.CurrentThread.CurrentCulture to "no" (norwegian) just before writing the data using WriteXML....
1
by: Greg R | last post by:
mydataset.WriteXml(strPath + "/my.xml"); produces this error [ArgumentException: URI formats are not supported. System.IO.Path.GetFullPathInternal(String path) +27...
0
by: Opie | last post by:
When using DataSet.WriteXml to write out the data of a dataset, it appends d2p1 to the beginning of each of the attribute names, which causes the program to crash on a subsequent load, as the...
3
by: Serdar C | last post by:
hello there, i am writing a program that generates random numbers and shows the numbers on a (x,y) chart.. i decided to use crystal reports to draw the chart and a dataset.readxml to read data.....
4
by: Wes | last post by:
Hello, I have an application using an xml dataset to store app and user settings. The problem I am having is related to writexml. I have a save button on my application that updates the dataset...
2
by: Martin | last post by:
Hi, I have found that it is possible to load data from a database into a dataset and then write the dataset to a file in the form of XML using the WriteXML method of the dataset. However...
0
by: Tom | last post by:
I have an XML file that serves as a mini-database for a .Net windows app. I use the dataset WriteXML method to keep it updated. In the code below, the value contained in the textbox txtBase is a...
2
by: UJ | last post by:
It appears when you do a DataSet.WriteXml ( <filename>, <writemode> ) it doesn't close the file immediately. Is that true ? The reason I think that is I have two programs that are going to be...
12
by: Rainer Queck | last post by:
Hi NG, I have no idea why, but since a while a dataset refuses to write to a specific xml file. I get the error message "Der Zugriff auf den Pfad...
0
kwheelis
by: kwheelis | last post by:
Hello All, Complete C# newbie here, so please go easy and feel free to ask any questions about the problem that I may not be clear on. I have a query that runs and its dataset is written to XML...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.