|
-
Nov 23rd, 2005, 11:16 PM
#1
Thread Starter
New Member
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.
-
Nov 26th, 2005, 05:38 PM
#2
Re: convert xml filled dataset to a datatable/base
-
Nov 27th, 2005, 12:15 PM
#3
Thread Starter
New Member
Re: convert xml filled dataset to a datatable/base
-
Nov 27th, 2005, 02:42 PM
#4
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.
-
Nov 27th, 2005, 02:44 PM
#5
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.
-
Dec 2nd, 2005, 05:38 PM
#6
Thread Starter
New Member
Re: convert xml filled dataset to a datatable/base
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|