RAD Studio |  |

Specifying Whether the Connection Automatically Initiates Transactions
See Also
Collapse All

Use the Attributes property to control the connection component's use of retaining commits and retaining aborts. When the connection component uses retaining commits, then every time your application commits a transaction, a new transaction is automatically started. When the connection component uses retaining aborts, then every time your application rolls back a transaction, a new transaction is automatically started.

Attributes is a set that can contain one, both, or neither of the constants xaCommitRetaining and xaAbortRetaining. When Attributes contains xaCommitRetaining, the connection uses retaining commits. When Attributes contains xaAbortRetaining, it uses retaining aborts.

Check whether either retaining commits or retaining aborts is enabled using the in operator. Enable retaining commits or aborts by adding the appropriate value to the attributes property; disable them by subtracting the value. The example routines below respectively enable and disable retaining commits in an ADO connection component.

Copy Code

    procedure TForm1.RetainingCommitsOnButtonClick(Sender: TObject);
    begin
      with ADOConnection1 do begin
        Close;
        if not (xaCommitRetaining in Attributes) then
          Attributes := (Attributes + [xaCommitRetaining])
        Open;
      end;
    end;
    procedure TForm1.RetainingCommitsOffButtonClick(Sender: TObject);
    begin
      with ADOConnection1 do begin
        Close;
        if (xaCommitRetaining in Attributes) then
          Attributes := (Attributes - [xaCommitRetaining]);
        Open;
      end;
    end;

Copy Code

    void __fastcall TForm1::RetainingCommitsOnButtonClick(TObject *Sender)
    {
      ADOConnection1->Close()
      if (!ADOConnection1->Attributes.Contains(xaCommitRetaining))
        ADOConnection1->Attributes = TXactAttributes() << xaCommitRetaining;
      ADOConnection1->Open()
    }
    void __fastcall TForm1::RetainingCommitsOffButtonClick(TObject *Sender)
    {
      ADOConnection1->Close()
      if (ADOConnection1->Attributes.Contains(xaCommitRetaining))
        ADOConnection1->Attributes = TXactAttributes() >> xaCommitRetaining;
      ADOConnection1->Open()
    }

See Also

Controlling Timeouts

Indicating the Types of Operations the Connection Supports

Indicating the Types of Operations the Connection Supports

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!