Solved

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

Posted on 2011-02-14
4
270 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

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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