OLE DB Provider Template Architecture

Data Sources and Sessions

The OLE DB provider architecture includes a data source object and one or more sessions. The data source object is the initial object that every provider must instantiate. When a consumer application needs data, it co-creates the data source object to start the provider. The data source object creates a session object (using the IDBCreateSession interface) through which the consumer connects to the data source object. ODBC programmers can think of the data source object as being equivalent to the HENV and the session object as equivalent to the HDBC.

Provider architecture

Together with the source files created by the OLE DB Provider Wizard, the OLE DB templates implement a data source object. A session is an object that corresponds to the OLE DB TSession.

Mandatory and Optional Interfaces

The OLE DB provider templates give you prepackaged implementations for all the required interfaces. Mandatory and optional interfaces are defined by OLE DB for several types of objects:

Note that the OLE DB provider templates do not implement the row and storage objects.

The following table lists mandatory and optional interfaces for the objects listed above, according to the OLE DB 2.6 SDK Documentation.

Component

Interface

Comment

Data source (CDataSource)

[mandatory] IDBCreateSession

[mandatory] IDBInitialize

[mandatory] IDBProperties

[mandatory] IPersist

[optional] IConnectionPointContainer

[optional] IDBAsynchStatus

[optional] IDBDataSourceAdmin

[optional] IDBInfo

[optional] IPersistFile

[optional] ISupportErrorInfo

Connection from the consumer to the provider. The object is used to specify properties on the connection such as user ID, password, and data source name. The object can also be used to administer a data source (create, update, delete, tables, and so on).

Session (CSession)

[mandatory] IGetDataSource

[mandatory] IOpenRowset

[mandatory] ISessionProperties

[optional] IAlterIndex

[optional] IAlterTable

[optional] IBindResource

[optional] ICreateRow

[optional] IDBCreateCommand

[optional] IDBSchemaRowset

[optional] IIndexDefinition

[optional] ISupportErrorInfo

[optional] ITableCreation

[optional] ITableDefinition

[optional] ITableDefinitionWithConstraints

[optional] ITransaction

[optional] ITransactionJoin

[optional] ITransactionLocal

[optional] ITransactionObject

The session object represents a single conversation between a consumer and provider. It is somewhat similar to the ODBC HSTMT in that there can be many simultaneous sessions active.

The session object is the primary link to get to OLE DB functionality. To get to a command, transaction, or rowset object, you go through the session object.

Rowset (CRowset)

[mandatory] IAccessor

[mandatory] IColumnsInfo

[mandatory] IConvertType

[mandatory] IRowset

[mandatory] IRowsetInfo

[optional] IChapteredRowset

[optional] IColumnsInfo2

[optional] IColumnsRowset

[optional] IConnectionPointContainer

[optional] IDBAsynchStatus

[optional] IGetRow

[optional] IRowsetChange

[optional] IRowsetChapterMember

[optional] IRowsetCurrentIndex

[optional] IRowsetFind

[optional] IRowsetIdentity

[optional] IRowsetIndex

[optional] IRowsetLocate

[optional] IRowsetRefresh

[optional] IRowsetScroll

[optional] IRowsetUpdate

[optional] IRowsetView

[optional] ISupportErrorInfo

[optional] IRowsetBookmark

The rowset object represents the data from the data source. The object is responsible for the bindings of that data and any basic operations (update, fetch, movement, and others) on the data. You always have a rowset object to contain and manipulate data.

Command (CCommand)

[mandatory] IAccessor

[mandatory] IColumnsInfo

[mandatory] ICommand

[mandatory] ICommandProperties

[mandatory] ICommandText

[mandatory] IConvertType

[optional] IColumnsRowset

[optional] ICommandPersist

[optional] ICommandPrepare

[optional] ICommandWithParameters

[optional] ISupportErrorInfo

[optional] ICommandStream

The command object handles operations on data such as queries. It can handle parameterized or non-parameterized statements.

The command object is also responsible for handling bindings for parameters and output columns. A binding is a structure that contains information about how a column, in a rowset, should be retrieved. It contains information such as ordinal, data type, length, and status.

Transaction (optional)

[mandatory] IConnectionPointContainer

[mandatory] ITransaction

[optional] ISupportErrorInfo

The transaction object defines an atomic unit of work on a data source and determines how those units of work relate to each other. This object is not directly supported by the OLE DB provider templates (that is, you create your own object).

For more information, see the following topics:

See Also

Reference

OLE DB Interfaces

Concepts

OLE DB Provider Templates (C++)