XML Dataset

M

Miro

If I am creating a dummy app and want to store some user settings is there
any harm in this:
(This program will be used only by 1 person at a time)

I create a dataset in the dataset designer,
Then during the 'run' of the application I check to see if the xml file
exists. If not, I create it with the XMLwrite.
Example: MySettingsDataset.WriteXml("MyData.xml",
XmlWriteMode.IgnoreSchema)

Then when the form loads, I always load the whole XML file into my dataset
as such:

MySettingsDataset.ReadXml("MyData.xml" )

From here on in the app runs off the settings in the dataset. If at anytime
a user pulls up a screen ( that allows the editing of the settings), they
hit save, and I write the whole dataset back to the XML.

It is my first attempt at using xml files. In this case since I designed
the XML file in the dataset designer, I am assuming I do not need to include
the schema, or even do something like this:
Dim xDataFromDataset As Xml.XmlDataDocument
xDataFromDataset = New Xml.XmlDataDocument(MySettingsDataset)
xDataFromDataset.Load("MyData.xml")

Because each time I am assuming I am always overwriting ALL of the xml file.

Am I correct in this simple example assumption?

Thanks,

Miro
 
C

Cor Ligthert[MVP]

Miro,

You can create this simple like this.

\\\
Dim ds as Dataset
dim dt as Datatable
ds.Tables.Add(dt)
dim c1 as datacolumn
dim c2 as datacolumn
dt.columns.add(c1)
dt.columns.add(c20
dim dr as datarow = dt.newrow
...
dt.rows.Add(dr)
///

Etc, typed in this message, so watch errros.

Cor
 
M

Miro

Thanks Cor,

I beleive I have already gotten this working.
-without doing it manually - created the dataset with the designer and then
instantiated it during the code.

Thank you for the reply,

Miro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top