• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Very Agent !!! ... How to use Transaction in ADO

Dear Adviser !

I use D5 +  + SQL 7.0

ADO(ADOConnection, ADOTable), DBGrid

I create a Master/Detail Form. The user could accept or refuse when they input data. My code here :

*----
Procedure EditData                       ;
Begin
      VatData.VAT.BeginTrans ;
      EnDiEdit(True)                    ;
End ;

Procedure EndiEdit(Flag : Boolean)  ;
Begin
   IF Flag  Then
        InputOrderForm.OrderADOTable.Edit ;
        InputOrderForm.DetailOrderADOTable.Edit ;
    End

    InPutOrderForm.DetailOrderSource.AutoEdit := Flag   ;
End;

Procedure SaveData                       ;
Begin
    VatData.VAT.CommitTrans             ;
    InPutOrderForm.OrderADOTable.Post            ;

    EnDiEdit(False)                     ;
End ;

Procedure UndoData                       ;
Begin
     VatData.VAT.RollbackTrans           ;
     InputOrderForm.OrderADOTable.Cancel ;
     InputOrderForm.DetailOrderADOTable.CanCel ;

     EnDiEdit(False)                     ;
End ;
*------

But when i call UndoData Procedure, The data of DetailOrderr Table is changed. The status of Order Table is Ok, no changed. How can i abort te data of DEtalOder table. The data of detailOrder is posted on Server automaticly, when i move record in DBGrid.

I try to set AutoEdit property of DataSourde with False . But still get that error.

Please show me how to abort the implicit posting in Detail Table (Master Table is Ok)

Thank for consider all

Beginner
0
NamCit
Asked:
NamCit
  • 3
1 Solution
 
aikimarkCommented:
you should probably rollback the updates in the reverse order in which they are applied.  
Thus:
    InputOrderForm.DetailOrderADOTable.CanCel ;
    InputOrderForm.OrderADOTable.Cancel ;
    VatData.VAT.RollbackTrans           ;
0
 
NamCitAuthor Commented:

Dear adviser !

The Data of DetailTable in DBGrid is Changed.

What should i do next ?!?!?
0
 
NamCitAuthor Commented:

Aha !!!
Sorry

It is ok
0
 
NamCitAuthor Commented:

Dear Mr aikimark !

Your code is only effect when i modify one record of DetailTable. But if i modify several records in DBGrid, your code is not effect. The data is posted automatic again.

How i retrieve the old information

Please take consider on my problem again.


0
 
LukA_YJKCommented:
I think the main idea of Transaction is that it is an atomar sequence of operations which can be executed or cancelled as a whole. So you don't need Post/Cancel, also Commit and Rollback must be operations on a whole Database and must affect all tables of this Database...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now