Results 1 to 6 of 6

Thread: convert xml filled dataset to a datatable/base

  1. #1

    Thread Starter
    New Member vbxPuppet's Avatar
    Join Date
    Nov 2005
    Location
    alabama
    Posts
    14

    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.

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: convert xml filled dataset to a datatable/base

    What kind of database?

  3. #3

    Thread Starter
    New Member vbxPuppet's Avatar
    Join Date
    Nov 2005
    Location
    alabama
    Posts
    14

    Re: convert xml filled dataset to a datatable/base

    MS SQL server DB.

  4. #4
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    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.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  6. #6

    Thread Starter
    New Member vbxPuppet's Avatar
    Join Date
    Nov 2005
    Location
    alabama
    Posts
    14

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width