SqlBulkCopy From CSV to SQL Datatable

Posted by Swapnil on Stack Overflow See other posts from Stack Overflow or by Swapnil
Published on 2010-05-24T18:03:33Z Indexed on 2010/05/24 18:11 UTC
Read the original article Hit count: 428

Filed under:
|
|

I'm using SQL Server 2005, VB.NET 2005. I want to be able to import a very large excel file into a SQL table called "XYZ"

I've done this by doing the following:
1. Save the excel file as csv.(Using SaveAs XLCSV option)
2. Build a datatable "ABC" From CSV.(using ODBC Connection and Select * from '*'.csv command)
3. copy the datatable"ABC" into database table "xyz" (using sqlBulkCopy.WriteToServer())

It works fine without any error but when i checked my database i found that data type for some columns has been changed and hence it didn't copy some of the records.Any help would be appreciated

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb.net