Solved

Problem in load excel data into dataset using datadapet.fill method

Posted on 2011-02-14
4
269 Views
Last Modified: 2012-08-13
Hi

When i load the excel data into dataset using datadapet.fill method, It shows empty cell value where invalid dates are present. I want to show the error of invalid date. kindly help to me to sort the issue.
0
Comment
Question by:Shahid-Abbasi
  • 3
4 Comments
 
LVL 12

Expert Comment

by:Mamtha1982
ID: 34886226
Then you should use, DataReader instead of Adapter.
1. Read the data using DataReader
2. Try Parse your date column to valid dates, if not possible alert to the user.

0
 

Author Comment

by:Shahid-Abbasi
ID: 34932993
same thing is happening while using a datareader aswell.
0
 

Accepted Solution

by:
Shahid-Abbasi earned 0 total points
ID: 35489553
After a long struggle, i am able to find the answer of this mistery. There could be multiple reasons, but the most possible reason is to add 'IMEX=1' in connectionstring. Other possible reasons are.


Connection String: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FilePath;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";

1) "HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.

2) "IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.

SQL syntax "SELECT * FROM [sheet1$]". I.e. excel worksheet name followed by a "$" and wrapped in "[" "]" brackets.

Important:

Check out the [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel] located registry REG_DWORD "TypeGuessRows".

That's the key to not letting Excel use only the first 8 rows to guess the columns data type. Set this value to 0 to scan all rows. This might hurt performance.

If the Excel workbook is protected by a password, you cannot open it for data access, even by supplying the correct password with your connection string. If you try, you receive the following error message: "Could not decrypt file."
0
 

Author Closing Comment

by:Shahid-Abbasi
ID: 35511025
strange, this issue is very common, but expert team is failed to provide me the solution of this issue,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Export import database 4 42
Replace &lt; with < 14 55
free scanner TWAIN can be operated with a Web application 9 39
Help with C#, MVC, razor. 6 23
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.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 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

20 Experts available now in Live!

Get 1:1 Help Now