B
Bmack500
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(filename)
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=COM</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=COM</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=COM</ou>
<ou>OU=anotherou,OU=yetanother,DC=GOOGLE,DC=COM</ou>
</ad>
</config>
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(filename)
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=COM</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=COM</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=COM</ou>
<ou>OU=anotherou,OU=yetanother,DC=GOOGLE,DC=COM</ou>
</ad>
</config>