If I compile a VB6 app on win7, ADODB.Connection e

2019-03-17 14:08发布

Class does not support Automation or does not support expected interface

I compiled some VB6 code on my Win7 x64 machine and the result .exe will not run correctly on any other machine.

VB6 code is just a new template .exe file with one button, a reference to "Microsoft ActiveX Data Objects 2.6 Library" and the following code in the button press event:

Dim db
Set db = New ADODB.Connection

It runs correctly on my machine, but no others (even other Win7 x64 machines) (Update: I found TWO other users where it runs and one of them is Jeff Atwood!, but most machines have the same problem)

I checked the references screen on both machines to see if a reference failed (it wouldn't compile then though and it compiles fine). Everything looks legit. On the 64 bit machines, the references go into SysWow64 instead of system32.

I've even compiled this successfully on a Vista 64 bit machine and had it run correctly. It's only the compile on the Windows 7 and then running on any other machine where the error happens.

Here are the results of running CompChecker on my box:

comp checker results on box

Registry info: ADODB.Connection has GUID HKEY_CLASSES_ROOT\CLSID{00000514-0000-0010-8000-00AA006D2EA4}

InprocServer32 is %CommonProgramFiles%\System\ado\msado15.dll

2条回答
\"骚年 ilove
2楼-- · 2019-03-17 14:57

This is a Windows 7 SP1 issue. See http://support.microsoft.com/kb/2517589 for workarounds.

There are other ways around this:

  1. Use ADO 2.8 instead (from Win 7 RTM disk)
  2. Use late-binding (probably the easiest)
  3. There are a million things that people are trying on this very long and angry thread: Breaking change in MDAC ADODB COM components in Windows 7 Service Pack 1

Also, another thing, msado15.dll is not supported on x64 Win 7 as listed here: http://support.microsoft.com/kb/983246. It's a big page, just search on msado15.dll.

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-17 14:58

Check out the version of the MDAC components in both machines using this tool

Also be sure that you are using the same SQL Server (guessing) version database, since I've noticed that SQL Server 2008 x64 works differents than previous versions handling connections (when using VB6)

查看更多
登录 后发表回答