Microsoft Knowledge Base Email Alertz

(223333) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 223333 - Last Review: August 5, 2004 - Revision: 4.3

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

This article was previously published under Q223333

On This Page

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.

MORE INFORMATION

The following files are available for download from the Microsoft Download Center:
OleDBorc.exe (http://download.microsoft.com/download/dasdk/sample3/1/w9xnt4/en-us/oledborc.exe)
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  (http://kbalertz.com/Feedback.aspx?kbNumber=119591/EN-US/ ) 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  (http://kbalertz.com/Feedback.aspx?kbNumber=255996/EN-US/ ) FIX: OLE DB Services Are Not Loaded When Execute() Is Called from ICommandText

APPLIES TO
  • Microsoft Data Access Components 1.5
  • Microsoft Data Access Components 2.0
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
Keywords: 
kbdownload kbconsumer kbdatabase kbfile kbhowto kboracle kbprovider KB223333
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate