Click here to Skip to main content
Rate this: bad
good
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);
    try	
    {
     _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 5:46am
Mike Jo334
Edited 16-Jan-13 6:07am
v2
Rate this: bad
good
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 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
 
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
  Permalink  
v2
Comments
Mike Jo at 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 at 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
good
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.
  Permalink  
Comments
Mike Jo at 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 at 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
0 Sergey Alexandrovich Kryukov 410
1 Abhinav S 260
2 Nirav Prabtani 252
3 Andreas Gieriet 155
4 Dave Kreskowiak 155
0 OriginalGriff 7,545
1 Sergey Alexandrovich Kryukov 6,757
2 Maciej Los 3,909
3 Peter Leow 3,693
4 CHill60 2,712


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
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