Data Source Objects and Session Objects

The OLE DB connection model defines how data and service components  (also referred to as service components) are located and activated. Two objects are the basis for the OLE DB connection model: the data source object and the session. To access an OLE DB provider, a consumer must first create an instance of a data source object. Each data provider is identified by a unique class identifier (CLSID) in the registry. You call CoCreateInstance, which creates an instance of the object through the object's class factory. The data source object exposes IDBProperties, which the consumer uses to provide basic authentication information such as user ID and password (for cases when the data source does not exist in an authenticated environment) as well as the name of the data source (file or database) containing the data to be accessed. It also exposes IDBInitialize, which the consumer uses to connect to the data source.

After a data source object has been successfully initialized, the consumer can call methods in IDBProperties to query the capabilities of a provider. These capabilities include the interfaces, rowset properties such as scrollability, transaction properties such as supported isolation levels, and the SQL dialects a provider supports. The consumer can also call methods in IDBCreateSession to create a session.

The session acts as a rowset, command, and transaction factory. A data provider that does not support commands exposes the IOpenRowset interface, which enables providers to expose their data directly as rowsets without the use of commands.