Send feedback on this topic.
Teradata.Client.Provider
Transaction Property
Example 



Teradata.Client.Provider Namespace > TdCommand Class : Transaction Property
Gets or sets the explicit transaction in which the TdCommand executes.
Syntax
'Declaration
 
Public Shadows Property Transaction As TdTransaction
'Usage
 
Dim instance As TdCommand
Dim value As TdTransaction
 
instance.Transaction = value
 
value = instance.Transaction
public new TdTransaction Transaction {get; set;}
public:
new property TdTransaction^ Transaction {
   TdTransaction^ get();
   void set (    TdTransaction^ value);
}

Property Value

TdTransaction object. The default value is a null reference.
Exceptions
ExceptionDescription
The Transaction property was changed while the TdCommand was in execute-state or there is an outstanding associated TdDataReader.
The TdCommand is closed / disposed.
Remarks
The TdConnection.BeginTransaction method must be used to create a TdTransaction object. Furthermore, the TdConnection associated with the TdCommand (Connection property) must be used to create the transaction. The methods used to execute a SQL request will throw an exception if the transaction associated with the command does not match the transaction associated with the connection (Connection property).
Example
The following example starts an explicit transaction.
public void StartTransaction( TdConnection cn, TdCommand cmd)
{
    cmd.Connection = cn;
            
    cmd.Transaction = cn.BeginTransaction();
}
Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdCommand Class
TdCommand Members