Click here to Skip to main content
12,758,605 members (34,622 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++
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);
     _ConnectionPtr pConn;
      HRESULT hr = pConn.CreateInstance (__uuidof (Connection));
      if (FAILED (hr))
       AfxMessageBox ("Can't create intance of Connection");

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!
Posted 16-Jan-13 6:46am
Mike Jo366
Updated 16-Jan-13 7:07am
Jochen Arndt167.1K
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You probably have installed the KB983246 update on your development system while it hasn't been installed on the other system. See[^].

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

To check programmatically if the new ADO is used on your development machine:
#ifdef _DEBUG // Don't show message on user systems
// See
CLSID ID = __uuidof(ADODB::_Connection);
::StringFromCLSID(ID, &lpszID);
TRACE1("ADO _Connection UUID: %s\n", lpszID);
if (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!"));

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
#if 1
// MS Fix
// See
// New libs:
// 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")
// Solution (excluding and renaming changed UUIDs)
// 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")
Mike Jo 17-Jan-13 2:31am
@Jochen Arndt: I already read the KB you mentioned before, but it mentioned the issue come from Windows 7 not Windows XP (SP3)
Jochen Arndt 17-Jan-13 2:45am
The KB983246 update was also available for XP SP3. See at the end of the KB link in the 'APPLIES TO' section: Windows XP SP3 is listed.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Mike Jo 16-Jan-13 22:55pm
At default, we create an ADO object without specifying CLSID. Anyway, do you give more detail what to do with CLSID to avoid the above issue?
Richard MacCutchan 17-Jan-13 5:26am
You are using pConn.CreateInstance (__uuidof (Connection)); but the response is telling you that it cannot find an interface with the CLSID of __uuidof (Connection), so you need to investigate why not. Presumably some COM library is not installed or it is the wrong version.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100