Over the course of the past three tutorials we have created an ASP.NET page that allows the visitor to upload and display an Excel spreadsheet in a
GridView. Our end goal is to allow the user to import the rows in the spreadsheet into the two tables of our application database, a task we will complete
in this fourth installment.
In Displaying the Uploaded Excel Spreadsheet we saw how to use an
OleDbConnection to programmatically connect to the Excel spreadsheet and bind it to the GridView. Likewise, we could use this same style
of coding to insert data into our application database tables - connecting to the SQL Server database from code within the ASP.NET page
and issuing the INSERT statements. A better approach, however, is to design a tiered architecture that separates out the different
responsibilities into different layers. Specifically, we will place the code for inserting data into our database into a separate Data Access
Layer (DAL), which we will create using Typed DataSets.
With the DAL created, we can then wrap up the page's core functionality: connecting to the Excel spreadsheet, enumerating its rows, and using the DAL
to insert the rows into the database. Read on to learn more!
Read More >