Solved

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

Posted on 2002-07-07
5
231 Views
Last Modified: 2010-04-04
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
Comment
Question by:NamCit
  • 3
5 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 20 total points
ID: 7136711
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
 

Author Comment

by:NamCit
ID: 7136720

Dear adviser !

The Data of DetailTable in DBGrid is Changed.

What should i do next ?!?!?
0
 

Author Comment

by:NamCit
ID: 7136722

Aha !!!
Sorry

It is ok
0
 

Author Comment

by:NamCit
ID: 7136777

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
 
LVL 3

Expert Comment

by:LukA_YJK
ID: 7137464
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now