DataSets, Xml and updating a database.

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

I have created a dataset and populated it via the ReadXML method.

i.e

DataSet dataset = new DataSet();
dataset.ReadXmlSchema(xsdPath);
dataset.ReadXml(xmlReader,XmlReadMode.ReadSchema);

This works fine and provides me with a dataset that matches the
datastructure of a sql database (done with the xsd schema) which
resides on the same server.

I now need to put this dataset into the database.

How do I do this?

I cannot find code examples anywhere!

Please can somebody provide me with an example?
 
Hi Rick:

You can either manually loop through the dataset building a SQL Command and
using its ExecuteNonQuery method. or you can create a dataadpater, set its
Insert Command and just call update on the dataset (you may need to also
provide a Delete and Update command).

An easy way is to just walk through the DataAdapter configuration wizard,
and use the fields that are in the XML Dataset. Then it will build those
commands for you. All you'll need to do then is call the adapter's Update
command passing in the dataset/datatable as a parameter.

HTH

Bill
 
Thanks for your help, I really appreciate it.
However,
how do I "create a dataadpater, set its
Insert Command and just call update on the dataset"

Does this work well when the dataset contains multiple tables?
 
Back
Top