Recently in exchange for Win7 64-bit system, today suddenly found that the previously written ADO Connection database code compiled after the windows2003 will be executed to:
_connectionptr.createinstance (__uuidof (Connection)) will be reported "do not support this interface" error, spent an afternoon to find N more information, finally resolved, and finally organized into the following, in case of later check.
Error performance
An environment that generates the error: Microsoft Visual C + + compiled on a machine that is built on Windows 7 Service Pack 1 (SP1) or Windows R2 sp-1 or a KB9823246 patch installation VeX Data Objects (ADO) applications that run on a lower version of the operating system receive the following error message:
Error message 1
Regdb_e_classnotreg (0X80040154)
Error message 2
E_pointer (0X80004003)
Error message 3
E_nointerface (0X80004002)
Error message 4
The type of the COM object cast that was not found is ' system.__comobject ' ADODB of the interface type. Connection. This operation failed because the interface IID {00001550-0000-0010-8000-00AA006D2EA4} QueryInterface call to the COM component failed with the following error: This interface is not supported (exception in HRESULT: 0x80004 002 (E_NOINTERFACE)). "
Example code:
#import "Msado15.dll" no_namespace rename ("EOF", "endoffile") int main () {CoInitialize (NULL); _connectionptr pconnection = Null;pconnection.createinstance ("ADODB. Connect "); HRESULT hr = pconnection.createinstance (__uuidof (Connection));//hr = = E_nointerface if (FAILED (HR)) {_com_error E (HR);: : MessageBox (NULL, E.errormessage (), "Error", MB_OK); This interface is not supported for return 0;} return 0;}
Cause of error
This issue is caused by some ADO interfaces that have been changed in Windows 7 SP1 to be associated with the new instance identifier (IID). The older IID interface is assigned to the following suffix:
_deprecated
For example, the interface _connection has been updated as follows:
- In Windows 7, and in earlier versions of Windows, the _connection IID is 00000550-0000-0010-8000-00aa006d2ea4.
- In Windows 7 SP1, the _connection iid 00001550-0000-0010-8000-00aa006d2ea4, and the IID of _connection_deprecated 00000550-0000-0010-8000-00aa006d2ea4.
If your application uses early binding to _connection, the application binaries store the new IID during compilation. Applications that run on low-level operating systems because the IID does not exist, this results in an error.
Some ADO APIs that are related to the platform are in ADO 2.7 and later versions. In a 64-bit version of Windows, these ADO APIs handle parameters using 64-bit data types, such as the longlong data type. However, applications that use these APIs still use long data types. Therefore, you receive a "Type Mismatch" error message when you try to run the macro.
Solution Solutions
1. Download the following file first
32-bit WIN7 system:msado60_backcompat_i386.tlb
64-bit WIN7 system (Intel platform):msado60_backcompat_i386.tlb and msado60_backcompat_x64.tlb
64-bit WIN7 system (AMD platform):msado60_backcompat_i386.tlb and msado60_backcompat_ia64.tlb
2. Take 32-bit system example
Register Msado60_backcompat_i386.tlb
1. Copy the msado60_backcompat_i386.tlb to the C:\Program Files\Common Files\system\ado\ Directory
2, then copy the C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe to the C:\Program Files\Common Files\system\ado\ Directory
3, run the cmd, respectively, enter:
pushd C:\Program Files (x86) \common Files\system\ado\ + ENTER
Regtlibv12.exe Msado60_backcompat_i386.tlb + ENTER
Note:
32-bit system requires registration:
msado60_backcompat_i386.tlb;
64-bit WIN7 system (Intel platform) requires registration:
msado60_backcompat_i386.tlbAnd
msado60_backcompat_x64.tlbThese 2 documents;
64-bit WIN7 system (AMD platform) requires registration:
msado60_backcompat_i386.tlbAnd
msado60_backcompat_ia64.tlbThese 2 documents;
3. Replace the program code
Will: #import "Msado15.dll" no_namespace rename ("EOF", "Endoffile")
To be replaced by: #import "msado60_backcompat.tlb" no_namespace rename ("EOF", "Endoffile")
4. Rebuild the solution to
Resources:
1, HTTP://SUPPORT.MICROSOFT.COM/KB/2517589/ZH-CN
2, http://blog.csdn.net/magic_andy/article/details/9225073
_connectionptr.createinstance (__uuidof (Connection)) "Does not support this interface" error resolution