2

I am migrating from Delphi 7 to Delphi XE4. With Delphi XE4, I am using FIBPLUS 7.5. Delphi 7 application is running fine but I am getting a runtime error in Delphi XE4:

"Project abc.exe raised exception class EFIBClientError with message frmABC.transRead: Transaction not active"  

PAS File

var
    transRead: TpFIBTransaction;
    ...
    ...
    //transRead is used like this
    with TpFIBQuery.Create(Self) do
    begin
      Database := dbMyDB;
      Transaction := transRead;
      SQL.Add ('Select .....');
      ExecQuery;
      Close;
      Free;
    end;    

  DFM File

  object transRead: TpFIBTransaction
    DefaultDatabase = dbMyDB
    TimeoutAction = TARollback
    Left = 192
    Top = 196
  end

I have searched all pas and dfm files in entire project. I have not found any statement like this:

transRead.Active := True;

But I did find following statement at many places:

if transRead.Active then
begin
..........
..........
end

I have also seen this at some places:

transRead.Active := False;

Don't we need to activate the transaction? Is it automatically activated? Please suggest me any clue on which should I focus to get rid of this "Transaction is not active" error.

2 Answers2

4

There are two ways: 1. Start the Transaction before execQuery or 2. Set the optionsfield qoStartTransaction in Options of TpFibQuery like:

Options := Options + [qoStartTransaction];
Fritzw
  • 524
  • 1
  • 6
  • 16
  • Why the change in the code? Delphi 7 is running fine and I am running same code in Delphi XE4. I don't think there could be any code change. –  Nov 26 '13 at 10:57
  • @nkp you can always use IFDEF, then the changes will not reflect your delphi 7 app. – EProgrammerNotFound Nov 26 '13 at 11:24
  • @MatheusFreitas - I have already searched for it. I didn't found any declaration or transaction opening code in $IFDEF. –  Nov 26 '13 at 11:31
  • @nkp for FIB you can set default Options in the FIB-Ide Tools, maybe these are different in your Setup for Delphi 7 and XE4? These can be the reason for different results – Fritzw Nov 26 '13 at 11:55
  • @Fritzw - Can you elaborate what are FIB-Ide Tools and what setting have to be looked there? –  Nov 26 '13 at 12:06
  • @nkb There should be a menu-entry in your IDE for FIB. I have no FIB installed anymore so i can not help further, but i think you should start your Transactions every time you need it yourself, so you have the control. And i think you should read the documentation from FIB and Firebird about transactions – Fritzw Nov 26 '13 at 12:36
  • @Fritzw - I have come to this link where StartTransaction is ticked in the screenshot. How can I open this screen here on my system to make this setting? http://www.devrace.com/en/fibplus/articles/4763.php –  Nov 26 '13 at 12:49
  • @nkb You should install the FIB Tools, and search your source for StartTransaction. You should manage your transactions self and "NOT" depend on a setting elsewhere. – Fritzw Nov 26 '13 at 13:01
0

I just set property AutoReconnect = True of TFIBDatabase and it worked.