Insert XML Files into Databases Using Xml2OleDb
page 4 of 4
by Andrew Mooney
Feedback
Average Rating: 
Views (Total / Last 10 Days): 43376/ 60

Code Sample Instructions and Conculsion

[Download Code]
Now let’s discuss using the sample code. Place all of the files from the download into a virtual directory. You do not need to compile the source, because I have included the assembly (.dll) file in the download. This sample creates tables in databases, but it does not create the database. You will need to create the database before adding XML data to it. I have included an empty Access database (Database.mdb) and an empty Excel database/workbook (Database.xls) for you to use. You need to give the ASP.NET process account (default is MACHINENAME\ASPNET) write permissions on the database file. For FoxPro/dBase this could be just an empty directory.

Navigate to the virtual directory you created. Enter the name of the XML file (must be in the same virtual directory). Don’t enter the path, just the file name (Authors.xml). I have included a sample XML file (Authors.xml) that you can use. Next, enter the OleDb connection string and click the submit button.

Example connection strings:
Access: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\database.mdb;
Excel: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\database.xls;Extended Properties=Excel 8.0;
FoxPro/dBase: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\data;Extended Properties=dBASE IV;
SQL Server: Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=database;User ID=sa;Password=;

When I started thinking about writing this article I imagined that code would be very complicated. I was very pleased to find out how few lines of code it took. That’s how easy ASP.NET makes it to add XML data into the OleDb database of your choice.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-03-05 8:19:18 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search