GeekArticles
Database
SQL ServerImporting an Excel Spreadsheet Using Typed DataSets and TableAdapters: Creating a Data Access Layer (DAL)
Author: aspnet.4guysfromrolla.com |
Published: 19th Mar 2008 |
Visited: 113 times |
Add CommentFiled in: SQL Server
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 >
Read Article Sponsored Links
Related Articles
• Speeding Up Data Submission The goal of building an Ajax based application is to ensure that interactivity of the site to the user is highly optimized. One of the main features of Ajax is to create an application that should predict what the user actually needs. As the user key in a letter the application will communicate to t ...
• Swing Extreme Testing - The Data Validation Test The Data Validation Test
The Ok button of the SaveAsDialog should only be enabled if the name that has been entered is valid. A name can be invalid if it contains an illegal character, or if it has already been use ...
• Access WSDL Access WSDL and Generate Axis Stubs to Access the Web Service Remotely
Now for the really cool stuff. As we discussed earlier, we have set up the ServiceMix as a separate web service gateway in front of the actual web service deployment. Now we have to check whether we can access the WSDL from the S ...
• Retrieving XML Data Retrieving XML DataTo retrieve XML data from an XMLType table, you can use a SELECT SQL statement, just as you would if you had to query a relational table. For example, to select the employee with the id set to 100 from the employees XMLType table discussed in the preceding section, you might issue ...
• Querying Data with Oracle XQuery Querying Data with Oracle XQuery
Starting with Oracle Database 10g Release 2, you can take advantage of a full-featured native XQuery engine integrated with the database. With Oracle XQuery, you can accomplish various tasks involved in developing PHP/Oracle XML applications, operating on any kind of ...
• Breaking up XML into Relational Data Breaking up XML into Relational Data
While the preceding example shows how to construct an XML representation over relational data, the example in this section illustrates how you can shred XML data back into relational data. This reverse operation can be useful if your application works with relati ...
• Accessing and Updating Data in ASP.NET 2.0: Using Optimistic Concurrency
Because multiple users can visit the same web page concurrently, it is possible for a user visiting a data modification page to inadvertently overwrite
the modifications made by another user. Consider a page with an editable GridView. If two users visit this page simultaneously from different compu ...