MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 2: Data Source and Session Objects


 

Session Objects

Session objects provide methods for creating commands and rowsets and for creating and modifying tables and indexes. They also define transaction scope and can be used to create transaction objects, which are used to control nested transactions.

The session object cotype is defined as follows. For more information about cotypes, see "OLE DB Objects" in Chapter 1, "Overview of OLE DB."

CoType TSession {
   [mandatory]   interface IGetDataSource;
   [mandatory]   interface IOpenRowset;
   [mandatory]   interface ISessionProperties;
   [optional]    interface IAlterIndex;
   [optional]    interface IAlterTable;
   [optional]    interface IBindResource;
   [optional]    interface ICreateRow;
   [optional]    interface IDBCreateCommand;
   [optional]    interface IDBSchemaRowset;
   [optional]    interface IIndexDefinition;
   [optional]    interface ISupportErrorInfo;
   [optional]    interface ITableDefinition;
   [optional]    interface ITransaction;
   [optional]    interface ITransactionJoin;
   [optional]    interface ITransactionLocal;
   [optional]    interface ITransactionObject;
}

If the session supports ITransactionLocal, the consumer can call ITransactionLocal::StartTransaction to start an explicit transaction. The session is then said to be in manual-commit mode, and any work done in the session must be explicitly committed or aborted. If ITransactionLocal is not supported or if the consumer does not call StartTransaction, the session is said to be in auto-commit mode, and any work done in the session is automatically committed. It cannot be aborted. For more information about transactions, see Chapter 15, "Transactions."

To create a session, a consumer calls IDBCreateSession::CreateSession on the data source object. A single data source object can support multiple sessions and, therefore, multiple transactions. From a session, the consumer can do the following: