Link to home
Start Free TrialLog in
Avatar of alsam
alsam

asked on

Transfer data from Excel to MS SQL Server database

Hi,
I'm trying to find on the web any good example for moving data from excel to SQL Server..
For this purpose I allready use SQL BulkCopy but what I'm interested in how to validate data types between source (excel worksheet) and destination table (on SQL Server database)...
Also, i'm get stuck on how to provide end users to manually mapp columns between 2 datasources using sqlBulcColumnMappings...
Link, code or some constructive advice would be very much appreciated...
Thanks in advance
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of alsam
alsam

ASKER

Thanks, but I allready have seen this article before...anyway thanks....
Regarding this part
 ' The column order in the source doesn't match the order
                ' in the destination, so ColumnMappings must be defined.
                bulkCopy.ColumnMappings.Add("ProductID", "ProdID")
                bulkCopy.ColumnMappings.Add("Name", "ProdName")
                bulkCopy.ColumnMappings.Add("ProductNumber", "ProdNum")

Do you maybe have any advice how to make this "user frendly"...I dont want to fix those columns in code but I want to let end user to make this mapping as he/she wants to... Something similar like in Import/Export Wizard in SQL Server...

Also, do you have any suggesstion about data type validation between 2 sources (excel vs. sql server db table)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial