How to disable connection auto opening on report loading in designer

Grzegorz MolendaGrzegorz Molenda Lublin, Poland
edited 8:17AM in FastReport VCL 5
Hi,

I have this problem with FR5 latest version, that when I'm loading report to designer, it is trying to connect to databse from FDConnection placed in this report.
Because this report is heavy, 27 requests to database is done when it starts, and the amount of work done by db server is more than 10 minutes long total, I need to stop this behavior.

I know that I can set Connected to False, but it's not enough. Person that edits this report can set it to True, and save it that way. And other person can load it with Connected = True, and than > 10 mins waiting for application to respond.

How can I prevent and stop auto connecting on loading of the report?

Thanks in advance, Grzegorz.

Comments

  • gpigpi
    edited 8:17AM
    You may set Connected to False in the TfrxReport.OnBeforeConnect event
  • Grzegorz MolendaGrzegorz Molenda Lublin, Poland
    edited 8:17AM
    gpi wrote: »
    You may set Connected to False in the TfrxReport.OnBeforeConnect event
    Nop, if I do this like that, I can't connect at all, even if I'm in design mode or preview mode.
  • gpigpi
    edited 8:17AM
    Set to false for design, set to true for preview
  • Grzegorz MolendaGrzegorz Molenda Lublin, Poland
    edited 8:17AM
    How to determine if I'm in design mode or preview?
  • gpigpi
    edited 8:17AM
    Set Boolean variable to true before DesignReport, to false before Show report and use it in the Before connect event
  • Grzegorz MolendaGrzegorz Molenda Lublin, Poland
    edited 8:17AM
    No, I mean from report designer, when I click preview button, how can I know in OnBeforeConnect which mode is it running (designing or preview)?

    My first problem regarding disabling connection on loading of report is resolved that way:
    procedure TMainForm.frxReport1BeforeConnect(Sender: TfrxCustomDatabase; var Connected: Boolean);
    begin
      if Sender.IsLoading then begin
        if (Sender is TfrxFDDatabase) then begin
          TfrxFDDatabase(Sender).ConnectionDefName:='';
          TfrxFDDatabase(Sender).DatabaseName:='';
        end
        else if (Sender is TfrxADODatabase) then begin
          TfrxADODatabase(Sender).DatabaseName:='';
        end
        else if (Sender is TfrxIBXDatabase) then begin
          TfrxIBXDatabase(Sender).DatabaseName:='';
        end
        else if (Sender is TfrxDBXDatabase) then begin
          TfrxDBXDatabase(Sender).DatabaseName:='';
        end;
        Connected:=False;
      end;
    
      Sender.LoginPrompt:=False;
    end;
    
  • gpigpi
    edited 8:17AM
    Use TfrxReport.OnBeginDoc event

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.