Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

OleDbOrc.exe: Using the OLE DB Cursor Engine Service to Provide Updatability for OLE DB Providers


View products that this article applies to.

This article was previously published under Q223333

↑ Back to the top


Summary

Some OLE DB providers, such as Microsoft's Oracle OLE DB Provider, do not support updating via IRowsetChange, although they do support updating via SQL UPDATE statements. In this case, the OLE DB Cursor Engine service can be used to allow the provider to be updatable via IRowsetChange.

OleDbOrc.exe is a self-extracting executable containing two files, SDKServiceSample.cpp and VCServiceSample.cpp, that demonstrate how to invoke the OLE DB services when using the Oracle OLE DB Provider so that you can get the IRowsetChange interface and perform updates, insertions, or deletions.

SDKServiceSample.cpp uses OLE DB SDK function calls while VCServiceSample.cpp uses the OLE DB Consumer template C++ classes.

To build the samples, bring the .cpp file into the Visual C++ development environment and choose Build. The program will ask whether you want a default workspace created, choose Yes.

↑ Back to the top


More information

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
FilenameSize
SDKServiceSample.cpp8KB
VCServiceSample.cpp3KB

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

↑ Back to the top


Keywords: kbdownload, kbconsumer, kbdatabase, kbfile, kbhowto, kboracle, kbprovider, KB223333

↑ Back to the top

Article Info
Article ID : 223333
Revision : 7
Created on : 8/5/2004
Published on : 8/5/2004
Exists online : False
Views : 555