Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL Excel VB.NET Server
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.
 
Thanks
Posted 7-Aug-11 3:58am
Mcmish513
Edited 7-Aug-11 7:08am
Kim Togo26.1K
v2
Comments
Walt Fair, Jr. at 7-Aug-11 12:54pm
   
Are you just trying to translate column names from Excel to the DB or is something more involved?
Mcmish at 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???
 
Thanx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Mcmish at 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 at 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 at 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 at 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
good
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 295
1 Maciej Los 280
2 Afzaal Ahmad Zeeshan 224
3 BillWoodruff 205
4 Sergey Alexandrovich Kryukov 195
0 OriginalGriff 6,499
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,193
3 Manas Bhardwaj 4,657
4 Maciej Los 4,120


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 11 Aug 2011
Copyright © CodeProject, 1999-2014
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