You'll need to configure a dataadapter to do it if simplicity is your goal.
You can use a CommandBuilder, the DataAdapter configuration wizard or write
your own (check out Bill Vaughn's 'Weaning Developers from the
CommandBuilder article for a great discussion on this -
www.betav.com ->
Articles -> MSDN). Depending on how you got the dataset populated will
dictate your next strategy. If you're loading it from another database, then
just set AcceptChangesDuringFill to false on each adapter you're doing a
SELECT with to populate each respective table (actually, I just reread your
post and see that you are getting the data from an XML Document not another
db - but just as an FYI - if you ever come across this and want to do a data
base to database transfer and must use ADO.NET - this should help you out
http://www.expansys.com/product.asp?code=125564 ) . Then, have an adapter
for each of the tables in the dataset pointing to the destination - and call
update on the parent most and then each of the descendants in the chain - if
tables aren't related then it doesn't much matter.
If you are manually creating the rows and don't have a RowState of Added
(and they don't already exist in the destination table - which they appear
not to if I understand you correctly)... then using an Adapter won't work
since it looks to rowstate to determine which command to fire. And if it's
not Added, then it won't fire an Insert command for that row. In that
instance, you'll need to create your command and parameters, then just loop
through calling ExecuteNonQuery on each row (which is essentially all that
the Adapter is doing).
The key is once you load your dataset, check HasChanges() immediately after
loading it. Depending on the XML you got it from (ie if it has a diffgram)
then you may or may not have rowstate. This is the key factor here. You
can also go bleeding edge and use Yukon's xml features (if you're interested
I'll explain ) but that's probably a bit out of scope based on the current
description.)
If I misunderstood anything or you need further clarification, please let me
know.
Cheers,
Bill