Board index » delphi » ttable.cancel on two tables

ttable.cancel on two tables

hi,

i have a great problem while programming a little db-aplication. i have
two dbgrids on a form and each of them is connected with a several table.
now, when i make changes in dbgrid1 i can say table1.cancel and i get the
old datas. same with dbgrid2. but what do i have to do, when i wish to
undo the changes after i made them in dbgrid1 and dbgrid2 ? when the
dbgrid-component lost the focus a post automatically will be generate. a
cancle now only works for the changes i made in the last modified dbgrid
(table).
till now i haven't find a way to make a undo-procedure. i there anybody
who can help me to find a solution ?

i hope i have described my problem understandable.

thanks and merry christmas.... tom

 

Re:ttable.cancel on two tables


The most direct method is to make use of a TDatabase component.  Attach
your Table and Query components to it and call the StartTransaction
method at a key point before beginning the edits (possibly in the
BeforeEdit event of the Table or Query - but I haven't tested it.)

In your Undo procedure, call the Rollback method which "undoes" all
changes since StartTransaction.

If all goes well, then you must call the Commit method to end the
process.

John Jasper

Other Threads