We help IT Professionals succeed at work.

Two identical(?) projects - one fails, one works

I have attached two seemingly identical VB Express 2010 projects... they both have identical (copied and pasted) code for Button1 to read data from an Excel spreadsheet and display it in a DataGrid... very simple.

However, one project consistently gives me an OLEdb error as you can see in the screenshot (untitled.jpg) and the other works fine... on the same machine (Lenovo W500 laptop)

I have gone through the compilation options, resources, MyProject files, etc for both projects, and I can find no difference. For instance, I made sure the target framework for both was ".NET Framework 4 Client Profile".

I am really scratching my head as to why one works and the other does not... can you detect some difference and/or explain the OLEdb error in this context?
Excel-OLEdb-read-tests.zip
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
FYI, both run identically for me (both error as they can't find Sheet1, not due to a provider problem).
Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
be sure that the project giving you the error is targeting the x86 platform (it seems to currently target the ANY cpu).
CERTIFIED EXPERT
Top Expert 2015
Commented:
The Jet Database Engine that is used to establish the connection is not recognized by 64-bits applications. You need to set the compilation to 32-bits, that is to x86 in order to work with the Jet, either to connect to Excel or to an Access database.

Author

Commented:
Emoreau and JamesBurger,<br /><br />You were correct in that the x86 platform was being targeted in one project and not the other, although I'm not sure why. <br /><br />I had to do some digging around to figure out how to add "x86" to the list of target CPU's, since only "Any CPU" was listed as an option at first. Once I figured out how to add "x86" and selected it, the project worked. <br /><br />Thanks.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.