VB.NET: "Provider cannot be found. It may not be properly installed" - Jet.OLEDB 4.0

Hi X-perts,

I am migrating to a new fresh PC with windows 7 and getting the above exception "Provider cannot be found. It may not be properly installed" when executing a simple

rc = New ADODB.recordset
Call rc.open(SQL,.....) '====> exception returned

I have checked all the references, MDAC versions etc. It looks fine (anyway, it is a working code from the XP machine).

Note that the code works OK, when called as a linked Excel COM. it returns exceptions only, if executed directly or when debugging.

What could be a problem here? What am I missing?

Who is Participating?
MCKreedConnect With a Mentor Commented:
Check out this link, it may help:

The links to the tips site keep bringing you to the home page of the site. To set the compiler to 32 bit go to the properties of your app, click compile and the advanced compile options. You can set the target CPU to x86.
Are you using 32 bit or 64 bit Windows?

andy7789Author Commented:
64 bit Win 7 Ultimate

My old machine was 32
andy7789Author Commented:
Thank you! It was the case. I have changed from Any PC to x86 and it works OK now. Any ideas why it was working before (Any PC target) when calling as COM from Excel?

It was the same ("Any PC") assembly.
if the Excel is x86 based then it would run under the x86 code base. The any CPU should normally work but I guess there are cases when it doesn't, as in this one. My guess, and it is just that, is using the any cpu allows it to be called from whatever the base the OS is, so running it from an x64 would not allow it to call the x86 jet provider. Setting it to x86 forces it to be called by the x86 code base allowing it to access the jet provider.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.