次の方法で共有


Simple Transactions

At any point in its lifetime, a session can be inside or outside a transaction. When created, a session is outside a transaction and all work done within the scope of that session and that is visible to the data store is immediately committed on each method call. (This is sometimes referred to as auto-commit mode or implicit mode.) When a session enters a transaction, all work done within the scope of that session and that is visible to the data store is part of that transaction and is committed or aborted as a single unit. (This is sometimes referred to as manual-commit mode.)

When the consumer calls ITransactionLocal::StartTransaction, a new local transaction is started. If there is already an active transaction on the session, the new transaction is started as a nested transaction below the current transaction. If the provider does not support nested transactions, calling StartTransaction when there is already an active transaction on the session returns XACT_E_XTIONEXISTS.

The transaction ends when the consumer calls ITransaction::Commit or ITransaction::Abort, at which time all changes to the rowset that have been transmitted to the data store are committed or aborted.

A single data source object can create multiple session objects, each of which can be inside or outside the scope of a transaction at any time.