Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Import an XML file into a SQL Database

Posted on 2003-12-02
2
Medium Priority
?
570 Views
Last Modified: 2010-04-16
I have an XML file of a database.  How do I convert or import this data into my sql database.  I have some code usin SQLXMLBulkLoad but it is in VB any body have any using C#
0
Comment
Question by:lyptus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Assisted Solution

by:TheAvenger
TheAvenger earned 200 total points
ID: 9862265
You can translate the code of VB.NET to C# very easily yourself or for example here:

http://www.ellkay.com/ConvertVB2CSharp.htm
0
 
LVL 6

Accepted Solution

by:
townsma earned 800 total points
ID: 9862809
I am assuming that it is the data that you wish to import and not the structure also. If this is the case you can use the ReadXML method of the dataset object to read you data in.  Below is a snippet of code that may help.

             //  Create a dataset an populate it with the structure of the table the data should be imported into.
             DataSet oDS = new DataSet("Select * from tablename");

              // Read the XML document back in.
              //Create new FileStream to read schema with. sFileName contains the name, and path, of the XML file to be imported.
              FileStream fsReadXml = new System.IO.FileStream(sFileName, System.IO.FileMode.Open);

              // Create an XmlTextReader to read the file.
              System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml);

              //Finally read the xml data into the dataset.
              oDS.ReadXml(myXmlReader);

              // Close the XmlTextReader
              myXmlReader.Close();


Hope this helps.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question