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.