Connections in ADOMD.NET - Performing Transactions
APPLIES TO:SQL Server Analysis ServicesAzure Analysis Services
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.
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.
Starting a 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();
Rolling Back a Transaction
Committing a Transaction
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.