Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Connection

Status
Not open for further replies.

sacsac

Programmer
Dec 10, 2000
177
GB
I have a VB2010/.NET4 program using ADO to connect to a Jet database, both reading and writing to it. It works just fine in the development environment, but when deploying on other machines it errors with the following:

************** Exception Text **************
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'ADODB.Connection'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00001550-0000-0010-8000-00AA006D2EA4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).


Is there some resource file which I should be including with the distribution?
 

There are different things that could cause this error, and different fixes.

1) If you are accessing database fields like this:

<recordset>("FieldName")

change it to:

<recordset>("FieldName").Value


2) If you are setting up your ADODB.Connection like this:

Dim cnn As ADODB.Connection
cnn = CreateObject("ADODB.Connection")

change it to this:

Dim cnn As ADODB.Connection
cnn = New ADODB.Connection()

3) You might need to install the latest version of the Micorsoft Data Access Components (MDAC) to the target PC.

4) You might need to install the Microsoft Access Runtime (AccessRuntime.exe) to the target PC.


All that said, I highly recommend rewriting your application to use ADO .NET to connect to your database, not the old ADODB. You'll avoid a lot of these problems that way.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks for your thoughts jebenson. I am using the syntax you give for creating the connection, however I am now currently downloading the AccessRuntime and MDAC to see if that works on the deployment PCs. The strange about this is that a few months back I distributed an application using ADODB and it runs perfectly all all machines. If I now recompile it it errors! I therefore think that there must be some change to my development environment causing the problem. ANyway, thanks again and I'll let you know the outcome of your recommendations.
 
Installed the AccessRuntime on XP SP3 machine to test, with negative result. Then tried installing MDAC, and it reports that all the MDAC functionality is contained within operating system. Completely stuck now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top