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
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
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.Ad d("Product ID", "ProdID")
bulkCopy.ColumnMappings.Ad d("Name", "ProdName")
bulkCopy.ColumnMappings.Ad d("Product Number", "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)
Regarding this part
' The column order in the source doesn't match the order
' in the destination, so ColumnMappings must be defined.
bulkCopy.ColumnMappings.Ad
bulkCopy.ColumnMappings.Ad
bulkCopy.ColumnMappings.Ad
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopycolumnmappingcollection.aspx#Y2800