[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • Last Modified:

Import excel spreadsheet into SQL 2005 using Visual Studio 2008

I need to find a way to import an excel spreadsheet into an SQL 2005 table.  I am developing a VB.NET application in Visual Studio 2008.  Can anyone give me some advice on how to accomplish this?
0
schwientekd
Asked:
schwientekd
  • 2
1 Solution
 
Bob LearnedCommented:
It is possible to use OLE DB to read the data from Excel, and then use an SqlBulkCopy to bulk insert the records into the SQL Server table.

Read Data from Excel using OLEDB in VB.NET 2005
http://vb.net-informations.com/excel-2007/vb.net_excel_oledb.htm

The SqlBulkCopy class
http://articles.techrepublic.com.com/5100-10878_11-6187181.html
0
 
schwientekdAuthor Commented:
I used the first link to import the spreadsheet data into a DataGridView and instead of a bulk insert I wrote a For Each loop to insert each row into the table.
0
 
Bob LearnedCommented:
The bulk insert is optimized over a For Each loop, so you might want to investigate it for the future, and see if it is faster...
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now