Click here to Skip to main content
13,152,454 members (37,802 online)
Rate this:
Please Sign up or sign in to vote.
I'm an Intern developing a tool to import data from excel with many sheets to sql server, i have been able to dynamically pass all the sheet names to combobox1 and sql server tables to combobox2. Further, combobox1.selecteditem(which is Excel Table) have passed all columns belonging to that selected table to Listview1 while combobox2.selecteditem have passed the sql table columns to listview4. How do i map the data of listview1.checkeditems(excel table columns) to the corresponding columns in listview4.checkeditems (sql table columns??=

And Option 2: I am also trying to import data directly from excel table (combobox1.selecteditem) to sql server table (combobox2.selecteditem)but it has foreign keys from many other tables. How to solve the foreign key constraint issue and what if some coulmn names are not the same from source to destination table???

Your kind and urgent response will serve my greatest interest.

I appreciates whatever effort put forth in helping me out.

Posted 7-Aug-11 2:58am
Updated 7-Aug-11 6:08am
Kim Togo27.1K
Walt Fair, Jr. 7-Aug-11 12:54pm
Are you just trying to translate column names from Excel to the DB or is something more involved?
Mcmish 7-Aug-11 21:27pm
Hi Walt,

thanks for your kind interest in helping out. i'm trying to import the data rows that belong to each column in a column by column format since the column names in excel sometimes differs with the column names of sql server table.

So, when i checked d excel table column i will also checked d sql server table corresponding column in order to avoid mismatch of data, so, i want to insert column by column. Any idea???

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Mcmish 8-Aug-11 4:59am
Thanx Sergey,

I really appreciates. I had tried similar methods already but its truncating the data cos of foreign keys constraint. And one of the methods will not be ideal as the column names differs at times and that will lead to either mismatch of data or truncating without inserting at all.

Any further assistance on how to solved the foreign keys issues to allow importing the selected table one after another would be highly appreciated.
losmac 9-Aug-11 16:02pm
There is no mechanism which will provide auto-conversion. You should know the structure of data in ms excel file and ms sql server (tables). The only one way to achieve this is to compare data "column by column". If user choose column1 in ms excel sheet and column1 in ms sql database table, you should compare it names and types of data, before start import.
Mcmish 9-Aug-11 21:32pm
Hi Losmac,

thnx. I guess i have achieve that feat of having to compare the names, but could you in any way show me sample of the data type comparison method, so I can pick it up from there? The data types includes nvarchar, int, decimal.

Thanx in advance.
losmac 11-Aug-11 14:20pm
And we have a problem, because comparison method does not exists! You need to write it. Tip: Try to convert data stored in table in ms excel file to expected format in ms sql database. If you expect help from me, i need to see an example: files, tables and code.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Dear all,

Kindly Check the link below to help me out here.I'm running late in my project, please....

Question: Map Excel Column to SQL Column

Thanx alot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170924.2 | Last Updated 11 Aug 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100