目标计算机上的ADO对象实例创建失败 [英] ADO objects instance creation failed on the target computer

查看:362
本文介绍了目标计算机上的ADO对象实例创建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装Windows XP SP3的开发计算机上使用VC ++ 6.0创建了一个MFC应用程序。在这个应用程序中,我使用ADO对象访问SQL数据库服务器:



I created an MFC application using VC++ 6.0 on my development computer installing Windows XP SP3. In this application, I used ADO objects to access SQL database server :

CoInitialize (NULL);
try
{
 _ConnectionPtr pConn;
  HRESULT hr = pConn.CreateInstance (__uuidof (Connection));
  if (FAILED (hr))
  {
   AfxMessageBox ("Can't create intance of Connection");
  }
  //...
}
//...

当然,应用程序在我的电脑上工作正常。但是,我复制了应用程序的整个Release文件夹,然后在安装了Windows XP SP3的另一台计算机上运行它,应用程序在创建Connection对象时失败,hr = -2147467262。



我在互联网上搜索了很多,但没有看到任何线索。



有谁知道这个问题,你能给我一些指导吗?

非常感谢!

Of course, the app works fine on my computer. However, I copied the whole Release folder of the app and then run it on another computer with Windows XP SP3 installed, the app failed at creating the Connection object with hr = -2147467262.

I searched on the internet much but don''t see any clue.

Does anyone know this issue and could you give me some guides on that?
Thanks a lot!

推荐答案

你可能已经安装了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.


这篇关于目标计算机上的ADO对象实例创建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆