且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

目标计算机上的ADO对象实例创建失败

更新时间:2022-12-23 12:10:10

你可能已经安装了KB983246更新了开发系统虽然没有安装在其他系统上。请参见 http://support.microsoft.com/kb/2517589/en-us [ ^ ]。



另请参阅您的ADO已损坏 [ ^ ]这里是CP,这是评论 [ ^ ]到文章。



[更新]

以编程方式检查开发机器上是否使用了新的ADO:

You probably have installed the KB983246 update on your development system while it hasn''t been installed on the other system. See http://support.microsoft.com/kb/2517589/en-us[^].

See also Your ADO is broken[^] here at CP and this comment[^] to the article.

[UPDATE]
To check programmatically if the new ADO is used on your development machine:
#ifdef _DEBUG // Don''t show message on user systems
// See http://support.microsoft.com/kb/2517589/en-us
CLSID ID = __uuidof(ADODB::_Connection);
LPTSTR lpszID = NULL;
::StringFromCLSID(ID, &lpszID);
TRACE1("ADO _Connection UUID: %s\n", lpszID);
if (lpszID)
    ::CoTaskMemFree(lpszID);
if (0x1550 == ID.Data1)
    AfxMessageBox(_T("App uses new ADO UUIDs.\nApp will not run with OS versions prior to Windows 7 SP1 or missing KB983246 update!"));
#endif





要解决此问题,您可以使用两种方法导入ADO类型库:



To fix this, you can use two methods to import the ADO typelib:

// Required for ADO / OLE DB.
// EOF is a global constant and must be renamed.
// Replace all occurences of "EOF" in ADO function names by "ADOEOF".
// The path must be adjusted according to the localized version of Windows.
// Optional omit the path and add it to the 'Additional path' C++ project settings.
//
// With Windows 7 SP1 or installed KB983246, the ADO DLL has been changed!
// See http://support.microsoft.com/kb/2517589/en-us
#if 1
// MS Fix
// See http://blogs.msdn.com/b/psssql/archive/2011/10/03/yes-we-made-a-mistake-and-are-finally-going-to-fix-it.aspx
// New libs: http://support.microsoft.com/kb/2640696?wa=wsignin1.0
// msado28.tlb: For Vista and later with MSJRO and for XP
// msado60.tlb: For Vista and later without MSJRO
#import "C:\Program files\Common Files\System\Ado\msado28.tlb" rename("EOF", "ADOEOF")
#else
// Solution (excluding and renaming changed UUIDs)
// http://www.codeproject.com/Articles/225491/Your-ADO-is-broken?msg=3959575#xx3959575xx
// NOTE: Use the extended import with excluding and renaming only when your
//  development machine uses Windows 7 SP1 or has KB983246 installed!
#import "C:\Program files\Common Files\System\Ado\msado15.dll" \
    rename("EOF", "ADOEOF") \
    exclude("_Connection", "_Command", "_Parameter", "_Recordset") \
    rename("_Connection_Deprecated", "_Connection") \
    rename("_Command_Deprecated", "_Command") \
    rename("_Parameter_Deprecated", "_Parameter") \
    rename("_Recordset_Deprecated", "_Recordset")
#endif


此值表示错误 0x8004002 这是 E_NOINTERFACE 。检查ADO DLL是否已安装在目标计算机上,并使用与开发系统上相同的CLSID。
This value represents error 0x8004002 which is E_NOINTERFACE. Check that the ADO dll is installed on the target machine and uses the same CLSID as on the development system.