How to import an Excel 2007 worksheet into a SQL Server 2005 table using C# with VS2010?

Posted on 2013-08-28
Medium Priority
Last Modified: 2013-08-31
I am developing a C# web application.

One of my methods titled ButtonImport_Click() has the objective of importing an Excel 2007 worksheet titled "Book Credits (D)" into a SQL Server table titled tbl_SMR_Book_Credits_D.

A sample Excel 2007 worksheet that I import is attached. I only import the worksheet titled "Book Credits (D)".

The fields of the SQL Server 2005 table tbl_SMR_Book_Credits_D are defined as follows:

Field Name        Data Type
--------------       ----------------
f1                      nvarchar(255)
f2                      nvarchar(255)
f3                      nvarchar(255)
f4                      nvarchar(255)
f5                      nvarchar(255)
f6                      nvarchar(255)
f7                      nvarchar(255)
f8                      nvarchar(255)
f9                      nvarchar(255)
f10                    nvarchar(255)
f11                    nvarchar(255)
f12                    nvarchar(255)
f13                    nvarchar(255)
f14                    nvarchar(255)
Question by:zimmer9
1 Comment
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 39453758
You could use OLEDB to get a DataTable, and then use the SqlBulkCopier to insert into an SQL Server table.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.
The PowerShell Core 6.0 of .NET release is just the beginning. The upcoming PowerShell Core 6.1 would have artificial intelligence and internet of things capabilities. So many things to look forward to in the upcoming release.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

627 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