CoCreateInstance fails with return code -2147221008

I'm calling

  HRESULT retval = CoCreateInstance(SQLNCLI_CLSID, NULL,
                                      CLSCTX_INPROC_SERVER,
                                      IID_IDBInitialize,
                                      (void **) &m_pIDBInitialize);

and it returns the above return code. I don't know what in the world it means or how to get an error message out of it.

The only possible return values for CoCreateInstance listed in

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686615%28v=vs.85%29.aspx

are

S_OK
REGDB_E_CLASSNOTREG
CLASS_E_NOAGGREGATION
E_NOINTERFACE
E_POINTER

#define S_OK                                   ((HRESULT)0L)
#define REGDB_E_CLASSNOTREG              _HRESULT_TYPEDEF_(0x80040154L)
#define CLASS_E_NOAGGREGATION            _HRESULT_TYPEDEF_(0x80040110L)
#define E_NOINTERFACE                    _HRESULT_TYPEDEF_(0x80004002L)
#define E_POINTER                        _HRESULT_TYPEDEF_(0x80004003L)

The values in decimal respectively are 0, 2147746132, 2147746064, 2147500034 and 2147500035. None of them is the value I got.

Please help before I shoot myself.


September 14th, 2013 2:32pm

Hello ,

I would suggest you to have a look at

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/f8417fdc-03e3-4f73-b165-b39a90fb1b90/cocreateinstance-fails-with-return-code-2147221008

It seems that the meaning of this error code is : "CoInitialize has not been called. "

As I have given up VC++ since the arrival of VS 2003 and VC# , I cannot give you more explanations.

A moderator may move your thread towards the VC++ forum if you want more explanations or help ( for myself , I prefer to do the move only after the original poster ( you PriorityCustomer ) has posted his/het agreement.

Have a nice day

Free Windows Admin Tool Kit Click here and download it now
September 15th, 2013 8:44pm

You were right. The documentation for CoCreateInstance should be corrected to explain this return value?
September 21st, 2013 6:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics