Search code examples
sql-servercomoledb

creating access to SQL Server Native Client OLE DB provider using CoCreateInstance fails with 80040154 error


I am trying to obtain access to SQL Server Native Client OLE DB provider using :

hr = CoCreateInstance(CLSID_SQLNCLI11, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize,

(void **) &PIDBInitialize);

and this fails with 80040154 error.

I am using sqlserver 2012 and everything worked perfectly fine as long as my application was running on the same machine as sql server was installed but now that the app is deployed in a different environment in which the app runs on a separate server than the server which has the database and sql server I am failing with this error even though the sql server version on the target server is same as mine.

Any ideas why would this behave in such way?

I appriciate your response.


Solution

  • Thats REGDB_E_CLASSNOTREG so CLSID_SQLNCLI11 is not available, download and install the redistributable package for the Native Client (Matching the bitness of your application).

    Download.