AdgConnection.BeginTransaction(String)

Begins a manual database transaction creating an instance of an IAdgTransaction object with the name specified.

        [C#]
public IAdgTransaction BeginTransaction(
   string Name
);
      
        [Visual Basic] 
Public Function BeginAutoTransaction( _
   ByVal Name As String
) As IAdgTransaction
      
        [Visual RPG]
 BegFunc BeginAutoTransaction Access(*Public) Type(IAdgTransaction)
   DclSrParm Name Type(*String)
      
Parameters
Name
A string naming the transaction.
Return Value

IAdgTransaction. A manual transaction object associated with the database connection.

Exceptions

ASNA.DataGate.Common.dgException is thrown to signal normal procedural conditions, in addition to error conditions. The following table summarizes these conditions, and the corresponding value of the dgException.Error property.

Value of
dgException.Error
Condition

dgEsAS400ERROR

The database server encountered a system error. Details are available via the SystemError and Text fields of dgException. For IBM i database providers, further details are available in the job log corresponding to the database connection.

Remarks

This method begins a manual transaction for those database providers that support transaction processing. The returned IAdgTransaction object representing the transaction is associated with the database connection of AdgConnection.

A manual transaction (as initiated by BeginTransaction) is distinguished from an automatic transaction (as initiated by the BeginAutoTransaction methods) by the behaviors of the IAdgTransaction.Commit and IAdgTransaction.Rollback methods. Commit and Rollback result in the acceptance and cancellation, respectively, of accumulated database modifications within the current transaction's boundaries. In an automatic transaction, these methods also result in the end of the current transaction followed by the immediate creation of a new transaction under the control of IAdgTransaction. Thus, the behavior of an automatic transaction is similar to the behavior of an IBM i database transaction for all database provider platforms.

Manual transactions should be used when an application requires a high degree of control over the transaction. Manual transactions can only be initiated with the BeginTransaction method. Further, manual transactions are not automatically renewed by DCS in the Commit and Rollback methods, as automatic transactions are. When multi-platform compatibility is of greater concern, use of automatic transactions is recommended (see BeginAutoTransaction). For the finest level of control over each transaction, use of manual transactions is recommended.

Name may be used by the database provider to identify transaction resources. Name initializes the Name property of the IAdgTransaction object returned. Specifying the empty string or a null reference for Name results in an anonymous transaction.

The value of the TransactionLevel property of the IAdgTransaction object returned is TransactionLevel.Medium.

Requirements