MDAC 2.5 SDK - OLE DB Providers
OLE DB Provider for Oracle


 

Data Source Objects

OLE DB uses the term data source for the set of OLE DB interfaces used to establish a link to a data store, such as Oracle. Creating an instance of the data source object of the provider is the first task of an OLE DB consumer. For more information about data source objects, see "Data Source Objects" in Chapter 2 of the OLE DB Programmer's Reference, "Data Source and Session Objects."

Every OLE DB provider declares a class identifier for itself. The class identifier for the OLE DB Provider for Oracle is the C/C++ macro CLSID_MSDAORA, which can be found in the header file Msdaora.h. With the class identifier, the consumer uses the OLE CoCreateInstance function to manufacture an instance of the data source object.

The Oracle provider is an in-process server. Instances of the Oracle provider objects are created using the CLSCTX_INPROC_SERVER macro to indicate the executable context.

The data source object exposes the OLE DB initialization interfaces that allow the consumer to connect to existing Oracle databases.

Example

This example uses the class identifier macro to create a data source object and get a reference to its IDBInitialize interface.

#include "msdaora.h"
IDBInitialize * pIDBInitialize;
HRESULT hr;

hr = CoCreateInstance(CLSID_MSDAORA, NULL, CLSCTX_INPROC_SERVER,
      IID_IDBInitialize, (void**) &pIDBInitialize);

if (FAILED(hr))
{
   // Display error
…
}

With successful creation of an instance of a data source object, the consumer application can continue by initializing the data source and creating sessions. OLE DB sessions expose the interfaces that allow data access and manipulation.

The provider makes its first connection to a specified Oracle server as part of successful data source initialization. The connection is maintained as long as a reference is maintained on any data source initialization interface, or until IDBInitialize::Uninitialize is called.

Note   The OLE DB Provider for Oracle looks for the file Ociw32.dll when the client application tries to initialize. If this file is not an Oracle version 7.3.3 or later file, or if the file is not found, the provider returns a message stating that IID_IDBInitialize failed: "The Oracle client and networking components were not found. These components are supplied by the Oracle Corporation and are part of the Oracle Version 7.3.3 (or greater) client software installation. You will be unable to use this provider until these components have been installed."