Session Objects

OLE DB Programmer's Reference

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 "Conceptual Programming Models in OLE DB" 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 ITableCreation;    [optional]    interface ITableDefinition;    [optional]    interface ITableDefinitionWithConstraints;    [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:

  • Create a command object by calling IDBCreateCommand::CreateCommand. A single session can support multiple commands. Some providers do not support commands.
  • Create a rowset by calling IOpenRowset::OpenRowset. This is equivalent to creating a rowset over a single table and is supported by all providers.
  • Create or modify tables and indexes with ITableDefinition and IIndexDefinition. Although providers are not required to support these interfaces, any provider built over a data store that supports creating and modifying tables and indexes should support them. For simple providers, such as a provider built over an array of data, ITableDefinition might be the only way to create or modify table definitions.
  • Create a schema rowset by calling IDBSchemaRowset::GetRowset, if the provider supports schema rowsets. For more information about schema rowsets, see Appendix B: Schema Rowsets.

1998-2001 Microsoft Corporation. All rights reserved.



Microsoft Ole Db 2.0 Programmer's Reference and Data Access SDK
Microsoft OLE DB 2.0 Programmers Reference and Data Access SDK (Microsoft Professional Editions)
ISBN: 0735605904
EAN: 2147483647
Year: 1998
Pages: 1083

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net