Solved

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

Posted on 2002-07-07
5
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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