PRB: DataLink Type Library Moved From MSDASC.DLL To OLEDB32.DLL In ADO 2.1ID: Q225132
|
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++:
The same #import of Msdasc.dll worked properly in ADO 2.0 but does not work in ADO version 2.1.fatal error C1083: Cannot open type library file: 'C:\Program Files\Common Files\System\OLE DB\msdasc.dll': Error loading type library/DLL.
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.
#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();
}
Additional query words: prompt oledb user connection dialog
Keywords : kbADO210 kbDatabase kbGrpVCDB
Version : WINDOWS:2.1
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 16, 1999