Subject Transaction management
Author sboydlns
I have some questions about transaction management. Suppose I have TIB_Connection (con1) and a TIB_Transaction (tran1). I set it up such that con1.DefaultTransaction := tran1. I then add a TIBOQuery (qry1) and set qry1.IB_Connection := con1 and qry1.IB_Transaction := tran1 and qry1.CommitAction := caFetchAll and qry1.FetchWholeRows := True. I then add a TDBGrid (grid1) and set the datasource to qry1 via a TDataSource component.

In my OnShow handler I do this:

con1.Connect;
trans1.StartTransaction;
qry1.Open;
trans1.Commit;

I would expect this to start a transaction, read all rows into qry1 and commit. I would expect there to be no active transactions at this point. However, con1.TransactionCount shows 2 transactions in total. con1.StartedTransactionCount shows 1 active transaction. And it will stay active for approx 1 minute and then I can see a second commit in the SQL monitor and StartedTransactionCount goes to zero.

How can I be certain that there are no active transactions?