convert xml filled dataset to a datatable/base
convert xml filled dataset to a datatable/base
ok i have a dataset I filled from a xml file, populated a datagrid with it (mostly to see if the data was really there), ok i got that much but I am very new to XML, so what i want to do is fill a database with the new data from the xml file. I have really not gotten any further theni started a week ago, to much coffee.
any help would be great, or suggestions links to code sample, all i have found was how to turn dataset into xml, but not the other way around I did search this forum but didnt find anything helpful to me.
thanks in advance.
Re: convert xml filled dataset to a datatable/base
Re: convert xml filled dataset to a datatable/base
Re: convert xml filled dataset to a datatable/base
You could create a stored procedure that inserts data to your db. Then loop through your dataset, and use the stored procedure to insert every row. Do a search for SqlCommand on MSDN, it is an object of the SqlClient namespace. The sqlcommand allows you to call stored procedures, or pass raw sql to the database.
Re: convert xml filled dataset to a datatable/base
You could loop through all items in the dataset and perform INSERT statements using the command object's executenonquery method.
Re: convert xml filled dataset to a datatable/base
Quote:
Originally Posted by mendhak
You could loop through all items in the dataset and perform INSERT statements using the command object's executenonquery method.
no worrys mate,
I got another script that converted my source file to an access db, then i just upgraded it to ms sql, had to set a little mapping though.
but as to what you say there above.
for a later day when something like this comes up again can you give an example of how you would loop through a xml dataset, then do an insert qry, into the db.
as a side note, should i have pre create the db in ms sql with the column names/datatypes. so when you run the loop/insert it whon't have to also create the db. or is there an easy way to create the db on the fly.
i do again thank you for all your help.