Performing Transactions in ADOMD.NET
Nuevo: 5 de diciembre de 2005
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.
[!NOTA] 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
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.
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.
Vea también
Referencia
Establishing Connections in ADOMD.NET
ADOMD.NET Client Programming