Solved

Import data from Excel to SQL Server through ASP.net C# - with validation

Posted on 2010-08-31
1
733 Views
Last Modified: 2012-05-10
Hi!

After the solution in Related Question was implemented, I was wondering if there any way to validate if the Excel sheet has the same structure of the table.

Is possible to validate this?

Thanks in advance!
0
Comment
Question by:calypsoworld
1 Comment
 
LVL 16

Accepted Solution

by:
carsRST earned 500 total points
ID: 33569392
Depends on what you mean by same structure.  If you mean column headers, you would use the Excel API to open the file and read each header and compare to database.  

Data type is another issue.  When you import as you're doing on the previous question, data type is determined by the first few rows.  If you need to test for sure, then you would also need to open the Excel file (see sample code) and perform a test on the sheet in the file.

Here's some sample code for opening an Excel file from c#.
http://support.microsoft.com/kb/302084
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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