[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
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

656 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