Solved

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

Posted on 2010-08-31
1
729 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

12 Experts available now in Live!

Get 1:1 Help Now