The error "Invalid procedure call or argument" in "New ADODB.Connection" only if it is compiled in Windows 7

I am having some problem compiling some legacy applications on VB6 since I have a new development machine in Windows 7. (My old one was in Windows XP.)

If I compile the project on my XP machine, everything is fine. If I compile the same project on my Windows 7 machine, it still works fine, but if I try to run it on an XP machine, I got this error.

Error Number: 5
Description: Invalid call or procedure argument

Thanks to my error handler, I know that the line that generates this error is:

    Dim objConn As ADODB.Connection
--> Set objConn = New ADODB.Connection

I compared the links on both machines, but they Project - Referencesmatch: (Microsoft ActiveX Data Objects 2.7 Library)

What can cause this error?

+5
source share
2 answers

This is a known Microsoft issue , but I don't think it was a mistake; I believe that compatibility was compromised for security reasons. The problem could exist in assemblies other than SP1 if you have installed a specific fix . Microsoft KB has several options. Here is another article containing the update.

We ran into this problem, and we decided to deploy the Backwards Compatibility patch on all the machines of the developer and replace all obsolete ADO links with the Backward Compatibility link. It worked well for us.

+2

1 Win7, ​​ SP2.

1 - ADO RTM Win7 RTM C:\Program Files (x86)\Common Files\System\ado .

ADO typelib , . , , ADO typelib:

@echo off
set regtlib="%windir%\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe"
set subinacl="%~dp0subinacl.exe"
set target_dir=%CommonProgramFiles%\System\ado
if not "%CommonProgramFiles(x86)%"=="" set target_dir=%CommonProgramFiles(x86)%\System\ado

copy "%~dp0msado28_old.tlb" "%target_dir%\msado28_old.tlb" > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /setowner=Administrators > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /grant=Administrators=F > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /setowner=Administrators > nul
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{2A75196C-D9EB-4129-B803-931327F72D5C} /grant=Administrators=F > nul
%regtlib% -u "%target_dir%\msado28.tlb"
%regtlib% "%target_dir%\msado28_old.tlb"

msado28_old.tlb subinacl.exe, , install.bat, .NET Framework 4.0 regtlibv12.exe.

, ADO Win7, Windows.

+4

All Articles