I am converting application written in DBExpress to use new FireDAC components. The basic things like opening the query, changing filter or ordering, displaying in grid are working correctly. But I am surprised that some functions behave differently in comparison to dbexpress and I cant seem to comprehend it.
My application contains database editor. When user opens the editor new
transaction is started by calling method TFDConnection::StartTransaction
. When the user clicks on OK button, the active transaction is committed and editor closes.
In editor I use two queries to edit records. In first query I manually compose SQL update command (like "update TEST set NAME='some name' where ID=1234
") and execute it. So far so good.
Second query is connected to TDBAdvGrid
(equivalent of TDBGrid
from TMS Software company) and have CachedUpdates = true
. If I change some record in that grid I call TFDQuery::Post
and TFDQuery::ApplyUpdates
.
Whats weird calling TFDQuery::ApplyUpdates
commits not only pending changes in this specific query, but all queries connected to instance of TFDConnection
. I thought that calling of ApplyUpdates
should issue SQL update calls but should not interfere with transaction control.
I want to give the user option to reject all changes made by him in database editor window. How to do it correctly ? Should I postpone call to ApplyUpdates
to time when closing window ? What is then the purpose of TFDQuery::CommitUpdates
and TFDConnection::Commit
if all that is necessary is the call of TFDQuery::ApplyUpdates
?
Set TFDConnection::TxOptions::StopOptions::xoIfCmdsInactive to false. This will also disable TFDConnection::TxOptions::AutoCommit option and application can controls transactions by itself.