Solved

Import multiple related Excel Files into SQL Server with asp.net/c#

Posted on 2013-12-04
1
1,001 Views
Last Modified: 2014-01-03
I have 4 excel files that I would like to import into a SQL Server database using and asp.net web form. Each of the 4 excel sheets go into 4 different (but related) tables. The excel file records each have an ID field, so you can see which records are related from excel file to excel file. That ID field is not in the SQL Server tables. They have an ID field, but the values are not the same between excel and sql server. Each record will get a new SQL id once it's imported. If this was just one sheet it would not be a problem. But excel file 1 needs to be imported, then each of the other 3 files with related records (but now with a new ID that does not match the SQL id). Is there a way to import by cycling through each record from all files? So the first record in excel file 1 (the parent) is imported into SQL Server and assigned a new ID, then each related record is imported from the other 3 files into their correct tables with the new SQL ID. The on to the next record. It seems quite cumbersome to me. Can something be worked out? Any help is appreciated.
0
Comment
Question by:dodgerfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
allanau20 earned 500 total points
ID: 39697426
say you imported the 4 excel files into their tables. In each table you should have the common ID field that the 4 tables can share just like you would in the 4 excel files? You can use that ID as the key to join (build relations) to the other tables. You don't have to match on the ID that SQL generated. What issues do you have with using the ID field from excel?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question