Solved

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

Posted on 2010-08-31
1
735 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
[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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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