If I compile a VB6 app on win7, ADODB.Connection errors with “Class does not support Automation or does not support expected interface”

老子叫甜甜 提交于 2019-12-20 17:27:07

问题


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:

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

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


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/5822886/if-i-compile-a-vb6-app-on-win7-adodb-connection-errors-with-class-does-not-sup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!