XML to SQL server help

C

ck

Does anyone have any examples up uploading XML data to SQL server? I can
get the xml doc in to an xmlreader object. I can display on the screen just
fine. I want to put this data in a dataadapter and post to to SQL server.
Any examples? Thanks everyone. Happy Monday!!

Regards,
CK
 
G

Guest

Create a dataset and use its ReadXML method to pull the XML doc into it.
Then, use a DataAdapter to update the DB from the dataset. You talked about
"uploading" - if these are all new rows as far as the DB is concerned, then
you need to instantiate a SQLCommand object and set the InsertCommand
property of the DataAdapter to point to it. If it does updates and deletes
then the DataAdapter will need an UpdateCommand and a DeleteCommand, as well.

If you need to give the user an opportunity to make changes to the data
before uploading, you might want to look into using a XMLDataDocument, which
is an XMLDocument object that is synchronized with a DataSet. When one is
changed, the other is automatically changed (actually two views of the same
data, if I'm not mistaken). A little more overhead, but very useful under
the right circumstances.

HTH
 

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