Page 1 of 1

I can not use the "BreakExec"

Posted: Sun 22 Apr 2018 17:46
by luapfr
I am doing several tests with IBDac and among these I found a very important functionality for my application.

I just can not get it to work because it gives me the error "invalid database handle (no active connection)"

But my code is right I do not understand why this error.

Code: Select all


type
  TQueryThread = class(TThread)
  private
    FConnection: TIBCConnection;
    FTransaction : TIBCTransaction;
    FQuery: TLFQuery;
  public
    procedure Execute ; override;
    function CancelOpening : Boolean;
    constructor Create;
    destructor Destroy; Override;
  end;

var
  Form1: TForm1;
  QueryThread: TQueryThread;

implementation

{$R *.dfm}

constructor TQueryThread.Create;
begin
  inherited Create(False);

  FreeOnTerminate := True;

  FConnection := TIBCConnection.Create(Nil);
  FConnection.Database := 'D:\Banco de Dados\Casual\Banco Antigo\DATA-EXPERT.DAE';
  FConnection.Username := 'SYSDBA';
  FConnection.Password := 'masterkey';
  FConnection.Connected := True;

  FTransaction := TIBCTransaction.Create(Nil);
  FTransaction.DefaultConnection := FConnection;
  FTransaction.Active := True;

  FQuery := TLFQuery.Create(nil);
  FQuery.Connection := FConnection;
  FQuery.Transaction := FTransaction;
  FQuery.SQL.Text := Form1.Memo1.Text;

end;

destructor TQueryThread.Destroy;
begin
  FQuery.Free;
  FConnection.Free;

  inherited;
end;

function TQueryThread.CancelOpening : boolean;
begin
  Result := not FQuery.Fetched;
  if Result then FQuery.BreakExec; // Error invalid database handle (no active connection)
end;

procedure TQueryThread.Execute;
begin
 inherited;

 FQuery.Open;

end;

procedure TForm1.Btn_OpenClick(Sender: TObject);
begin
 QueryThread := TQueryThread.Create;

end;

procedure TForm1.Btn_CancelClick(Sender: TObject);
begin
 if QueryThread.CancelOpening then
  Showmessage('Cancelou')
 Else
  Showmessage('Executando');

end;

See the Code below and the link is the application if you wanted to test there.

I have not put the database to be very large however you can use any database of yours that has a large table.
https://mega.nz/#!JmZ1lQKA!QhA3vVVyPWiK ... 3vuZ__oam8

Re: I can not use the "BreakExec"

Posted: Tue 24 Apr 2018 10:53
by ViktorV
Thank you for the information. We have reproduced the issue and investigation is in progress. We will inform you when we have any results.

Re: I can not use the "BreakExec"

Posted: Thu 26 Apr 2018 06:34
by ViktorV
We have fixed the issue. This fix will be included in the next build of IBDAC.
We can send you a IBDAC night build including the fix. Please provide your license number and IDE version to viktorv*devart*com and we will send you a night build.