Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-31
1
Medium Priority
?
736 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 2000 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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 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