Export (0) Print
Expand All

Performing Transactions in ADOMD.NET

In ADOMD.NET, you use the AdomdTransaction object to manage transaction context for a given AdomdConnection object. This functionality allows you to run several commands within the same context. Each command will read the same data without the read data changing between each command execution.

Note Note

The AdomdTransaction class is the implementation of the System.Data.IDbTransaction interface, part of the Microsoft .NET Framework Class Library and implemented by all .NET Framework data providers that support transactions.

The AdomdTransaction object only supports read-committed transactions, in which shared locks are held while the data is being read to avoid dirty reads.

The AdomdConnection is used to start the transaction. To use the transaction, commands are then run against the connection that started the transaction. When you are finished with the transaction, you can either be roll back or commit the transaction.

You create an instance of an AdomdTransaction object by calling the BeginTransaction method of the AdomdConnection object. The following example shows how to create an instance of the AdomdTransaction object:

Dim objTransaction As AdomdTransaction = objConnection.BeginTransaction()
AdomdTransaction objTransaction = objConnection.BeginTransaction();

To roll back an existing, incomplete transaction, you call the Rollback method of the AdomdTransaction object. If you call this method on an existing, complete transaction, an exception is thrown.

After you call the BeginTransaction method to start a transaction, you can complete the transaction by calling the Commit method of the AdomdTransaction object. If this method is called on an existing, complete transaction, an exception is thrown.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft