Navigation:  Advantage .NET Data Provider > AdsCommand Class > AdsCommand Properties >


Advantage .NET Data Provider

Previous pageReturn to chapter overviewNext page

Gets or sets the transaction in which the AdsCommand executes.

public AdsTransaction Transaction {get; set;}


This property can be used to store a transaction object. With the Advantage .NET Data Provider, it is not necessary to assign this property in order to use the AdsCommand object within a transaction. With Advantage Database Server, all commands executed on an AdsConnection while that connection has a transaction active are automatically run in that transaction.

Advantage Local Server does not support transactions. To use transactions, it is necessary to use Advantage Database Server.


This example performs an update statement within a transaction. It uses the Transaction property of the command object to store the transaction object and retrieves it after the UPDATE statement to perform the commit.

// create a connection object

AdsConnection conn = new AdsConnection( "data source = c:\\data;" );

AdsCommand cmd;


// open the connection


// create a new command object and start a new transaction

cmd = new AdsCommand( "update departments set budget = budget * 1.05",

conn, conn.BeginTransaction() );

// execute the query


// commit the transaction


// close the connection.


See Also