PRB: DataLink Type Library Moved From MSDASC.DLL To OLEDB32.DLL In ADO 2.1

This article was previously published under Q225132
This article has been archived. It is offered "as is" and will no longer be updated.
An attempt to #import Msdasc.dll to gain access to the DataLink COM object and OLE DB connection dialog results in the following compiler error in Visual C++:
fatal error C1083: Cannot open type library file: 'C:\Program Files\Common Files\System\OLE DB\msdasc.dll': Error loading type library/DLL.
The same #import of Msdasc.dll worked properly in ADO 2.0 but does not work in ADO version 2.1.
The type library for the DataLink COM object is no longer in Msdasc.dll. The type library has been moved into Oledb32.dll.
Change Msdasc.dll to oledb32.dll in your #import statement.
This behavior is by design.
More information

Steps to Reproduce Behavior

The following code sample demonstrates how to use the DataLink COM object in Visual C++ using the #import directive.

  1. Create a blank console project and insert a new .cpp file named Main.cpp
  2. Insert the code below.
  3. Switch the #import of Msdasc.dll with Oledb32.dll in order to use the DataLink COM object with ADO 2.1.

   #include "stdio.h"   #include "conio.h"   // #import ADO.   #undef EOF   #import "c:\program files\common files\system\ado\msado15.dll"\<BR/>no_namespace   // In ADO 2.0, you would use the following #import statement.   #import "c:\program files\common files\system\ole db\msdasc.dll"\ no_namespace    // Copy and paste of this code might result in escape sequence error  //during compile time. You can either write the whole #import statement //in one line, or make sure that there is no space after escape sequence                                              //"\".         // In ADO 2.1 use the following #import statement.   //#import "c:\program files\common files\system\ole db\oledb32.dll" \    //  no_namespace   void main()    {     HRESULT hr;     IDataSourceLocatorPtr dlPrompt = NULL;     _ConnectionPtr conn = NULL;     _RecordsetPtr rs = NULL;     // Initialize COM     ::CoInitialize( NULL );     try     {       // Instantiate DataLinks object.       hr = dlPrompt.CreateInstance( __uuidof( DataLinks ) );       if ( FAILED( hr ) ) throw( _com_error( hr, NULL ) );       // Prompt for connection information.       conn = dlPrompt->PromptNew();       // If connection object is NULL, user cancelled.       if ( NULL == conn ) goto Exit;       // Open connection (connection returned by DataLinks is just       // a holder for the returned ConnectionString).       conn->Open( conn->ConnectionString, L"", L"", -1 );        // Get a list of tables and dump list to console.       rs = conn->OpenSchema( adSchemaTables );       printf( "Listing tables:\n" );       while ( !rs->EOF )       {         printf( "%s\n",              (char*) (_bstr_t)              rs->Fields->Item[L"TABLE_NAME"]->Value );         rs->MoveNext();       }     }     catch ( _com_error &ce )     {       // Trace COM error information.       printf( "\nCom Exception Information\n" );       printf( "Description : %s\n",   (char*) ce.Description()  );       printf( "Message     : %s\n",   (char*) ce.ErrorMessage() );       printf( "HResult     : 0x%08x\n", ce.Error() );     }   Exit:     printf( "DataLink test complete. Press any key to exit test.\n" );     _getch();   }				

NOTE: ADO 2.1 is available with MDAC 2.1, whereas ADO 2.0 is shipped with MDAC 2.0.
prompt oledb user connection dialog

Article ID: 225132 - Last Review: 10/26/2013 04:08:00 - Revision: 2.0

  • Microsoft ActiveX Data Objects 2.7
  • kbnosurvey kbarchive kbdatabase kbDSupport kbprb KB225132