Session Object Example
The code in this example shows how to create a session object.
/////////////////////////////////////////////////////////////////
// myCreateSession
//
// Create an OLE DB Session object from the given DataSource
// 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;
}