Microsoft OLE DB 2.0 Programmers Reference and Data Access SDK (Microsoft Professional Editions)

OLE DB Programmer's Reference

The code in this example shows how to create a session object.

///////////////////////////////////////////////////////////////// // myCreateSession // // Create an OLE DB session object from the given data source // object. The IDBCreateSession interface is mandatory, so this // is a simple operation. // ///////////////////////////////////////////////////////////////// HRESULT myCreateSession ( IUnknown *           pUnkDataSource, IUnknown **          ppUnkSession ) { HRESULT              hr; IDBCreateSession *   pIDBCreateSession = NULL; //Create a session object from a data source object. XCHECK_HR(hr = pUnkDataSource->QueryInterface(  IID_IDBCreateSession, (void**)&pIDBCreateSession)); XCHECK_HR(hr = pIDBCreateSession->CreateSession(  NULL,               // pUnkOuter  IID_IOpenRowset,    // riid  ppUnkSession ));    // ppSession CLEANUP: if( pIDBCreateSession ) pIDBCreateSession->Release(); return hr; }

1998-2001 Microsoft Corporation. All rights reserved.

Категории