Solved

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

Posted on 2013-12-04
1
939 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Create XML 5 33
install app on other machine 13 13
C# TextBox 11 12
C# replace string in void with dR["myData"].ToString() 3 0
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now