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
LVL 1
alsamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alsamAuthor Commented:
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)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
0
CodeCruiserCommented:
To allow user to do the mapping, you can design a form with may be a grid with two columns each populated as a combobox with column names from either side. Then you can loop through this grid and add the mappings like

For i As Integer = 0 to dgv.Rows.Count - 1
     bulkCopy.ColumnMappings.Add(dgv.Rows(i).Cells(0), dgv.Rows(i).Cells(1))
Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

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.