?
Solved

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

Posted on 2002-07-07
5
Medium Priority
?
243 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 46

Accepted Solution

by:
aikimark earned 60 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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