The
following files are available for download from the Microsoft Download
Center:
For
additional information about how to download Microsoft Support files, click the
following article number to view the article in the Microsoft Knowledge Base:
119591�
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
Collapse this tableExpand this table
Filename | Size |
---|
SDKServiceSample.cpp | 8KB |
VCServiceSample.cpp | 3KB |
Invoking OLE DB Services, Such As the OLE DB Cursor Engine
To use such OLE DB services as the Cursor Engine, refer to the
Data Access SDK documentation or the Microsoft Platform SDK documentation on
the Microsoft Developer Network CD. Specifically, look up "OLE DB Services." To
use OLE DB services, you must use IDataInitialize or IDBPromptInitialize.
Following is the sample code from the OleDbOrc sample:
Sample Code
// The Init Prompt
InitProperties[0].dwPropertyID = DBPROP_INIT_PROMPT;
InitProperties[0].vValue.vt = VT_I2;
InitProperties[0].vValue.iVal = DBPROMPT_NOPROMPT;
// Data source string.
InitProperties[1].dwPropertyID = DBPROP_INIT_DATASOURCE;
InitProperties[1].colid = DB_NULLID;
InitProperties[1].vValue.vt = VT_BSTR;
InitProperties[1].vValue.bstrVal = SysAllocString(OLESTR("dseoracle"));
// User ID.
InitProperties[2].dwPropertyID = DBPROP_AUTH_USERID;
InitProperties[2].vValue.vt = VT_BSTR;
InitProperties[2].vValue.bstrVal = SysAllocString(OLESTR("demo"));
// Password.
InitProperties[3].dwPropertyID = DBPROP_AUTH_PASSWORD;
InitProperties[3].vValue.vt = VT_BSTR;
InitProperties[3].vValue.bstrVal = SysAllocString(OLESTR("demo"));
// Load the service components.
InitProperties[4].dwPropertyID = DBPROP_INIT_OLEDBSERVICES;
InitProperties[4].vValue.vt = VT_I4;
InitProperties[4].vValue.lVal = DBPROPVAL_OS_ENABLEALL;
rgInitPropSet.guidPropertySet = DBPROPSET_DBINIT; // The property set.
rgInitPropSet.cProperties = 5; // # of properties being set.
rgInitPropSet.rgProperties = InitProperties; // Array of DBPROP structures.
...
if (FAILED(hr = CoCreateInstance(CLSID_MSDAINITIALIZE, NULL,
CLSCTX_INPROC_SERVER, IID_IDataInitialize,
(void**)&pDataInit)))
RETURN(hr)
// Creating the IDBInitialize.
if(FAILED(hr = CLSIDFromProgID(wszProvider, &clsid)))
RETURN(hr)
if(FAILED(hr = pDataInit->CreateDBInstance(clsid, NULL,
CLSCTX_INPROC_SERVER, NULL, IID_IDBInitialize, (IUnknown**)
&pDataSourceIDBInitialize)))
RETURN(hr)
// Setting the initialization properties.
if(FAILED(hr = pDataSourceIDBInitialize->QueryInterface(IID_IDBProperties,
(void**)&pProperties)))
RETURN(hr)
if(FAILED(hr = pProperties->SetProperties(1,&rgInitPropSet)))
RETURN(hr)
if (FAILED(hr = pDataSourceIDBInitialize->Initialize( )))
RETURN(hr)
Notice the setting of DBPROP_INIT_OLEDBSERVICES. If you are using
the Visual C++ 6.0 ATL OLE DB Consumer templates, you can use the
OpenWithServiceComponents() function. For example:
CDataSource ds;
ds.OpenWithServiceComponents("MSDAORA", propset);
Once the datasource is opened using the service components, any rowsets
created with ICommand::Execute() use the cursor engine if the provider doesn't
provide the necessary functionality (scrolling and updating for
example).
NOTE: If the OLE DB consumer asks for ICommandText and calls Execute,
the services will not be used. You must use QueryInterface() for ICommand and
then query for ICommandText from that pointer.
For additional
information about this, please see the following article in the Microsoft
Knowledge Base:
255996�
FIX: OLE DB Services Are Not Loaded When Execute() Is Called from ICommandText