FastReport very slow in generating reports!

edited December 2014 in FastReport VCL 5
Hi
Please let me know what is the problem! I have a stored procedure work very fast, shows about 1000 rows in just less than a sec, but FastReport takes too long maybe 15 minutes to generate the report using the same stored procedure!
I call the report using a procedure (because I have more than 20 reports in my program I wrote a procedure to call a specific report), the procedure code is as bellow:

type
  TReportParams = array [1 .. 100, 1 .. 2] of string ;

procedure ShowFastReport(ReportParam: TReportParams; ReportName: string; rptDataSource: TDataSource);
var
  VIdx,
  Count: integer;
  Variable: TfrxVariable;
  tmp: string;
begin
  frmReport.frxReport1.Clear;
  frmReport.frxReport1.LoadFromFile(ReportName);
  if Software.DecimalQTY = 2 then
    SetCrParam(ReportParam, 'DisplayFormat', '#,##0.00;(#,##0.00);-;-')
  else
    SetCrParam(ReportParam, 'DisplayFormat', '#,##0;(#,##0);-;-');
  SetCrParam(ReportParam, 'CustomerName', ShowCompanyName);
  SetCrParam(ReportParam, 'ReportName', ExtractFileName(ReportName));
  SetCrParam(ReportParam, 'UserName', CRMUser.UserName);
  SetCrParam(ReportParam, 'ReportDate', GetMessageBody(286) + CRMUser.GetDate);
  SetCrParam(ReportParam, 'WebURL', 'RayaCRM3: www.rayacrm.com');
  for Count := 1 to frmReport.frxReport1.Variables.Count do
  begin
    if ReportParam[Count, 1] <> 'nil' then
    begin
      VIdx := frmReport.frxReport1.Variables.IndexOf(ReportParam[Count, 1]);
      if VIdx <> -1 then
      begin
        Variable := frmReport.frxReport1.Variables.Items[VIdx];
        Variable.Value :=  QuotedStr(ReportParam[Count, 2]) ;
      end;
    end;
  end;
  frmReport.frxDBDataset1.DataSource := rptDataSource;
  frmReport.frxReport1.ShowReport();
end;

On the frmReport form I have frxReport1 and frxDBDataset1 only. the report file (fr3) is attached to this post and there is nothing complicated inside the report! a Master detail attached to frxDataset1.

when I call the ShowFastReport procedure it shows me a blank report and after about 1 minute it fills page 1 and so on.

p.s: I am new on fast report and want to migrate from crystal reports to fast report. I download VCL 5 for delphi 2010. MS SQL 2008 R2 database - Operating system: Windows 7 - 32bit - SP1

Regards

Comments

  • gpigpi
    edited 8:16PM
    Did you disable controls for your Data source?
  • edited December 2014
    gpi wrote: »
    Did you disable controls for your Data source?

    Hi
    Thanks for the reply.
    I am not sure if I got your meaning by disable controls of data source, but let me explain, except the report I am trying to generate, there is a cxGrid bounds to the same data source, when user click on the create report button, I call the procedure mentioned in my previous post, after I read your reply I add a line of code to unbound the grid and then call the procedure but result is same!
    procedure TUserProjects.btnCreateReportClick(Sender: TObject);
    var
      ReportName: string;
    begin
    //Check If user has permission to run the report  
      if not CRMUser.HaveThisRight ((sender as TBitBtn).Tag, true) then
        Exit;
      
      ReportName := Software.ServerPath + '\FReports\UserProjectsNew.fr3';
    
    //Clear the report param list
      EmptyReportParams(CrParams);
    
    //validate report param list
      SetCrParam(CrParams, 'UserCaption', GetMessageBody(666));
      SetCrParam(CrParams, 'ReportCaption', GetMessageBody(288));
      SetCrParam(CrParams, 'RowCaption', GetMessageBody(314));
      SetCrParam(CrParams, 'LastDate', GetMessageBody(293));
      SetCrParam(CrParams, 'ProjectLabel', GetMessageBody(291));
      SetCrParam(CrParams, 'ProjectStep', GetMessageBody(290));
      SetCrParam(CrParams, 'ProjectName', GetMessageBody(40));
      SetCrParam(CrParams, 'Target', CRMUser.UserName);
      SetCrParam(CrParams, 'RequestDate', GetMessageBody(365));
      SetCrParam(CrParams, 'Reason', GetMessageBody(375));
    
    //call fastreport
      ShowFastReport(CrParams, ReportName, DMMain.dsUserProjects);
    end;
    
  • edited 8:16PM
    TDataSet.DisableControls
    See: http://docwiki.embarcadero.com/Libraries/X...DisableControls

    If you do not want to loose time searching for slow code you can use a profiler.

    Best regards,
    Cristian Peta
  • gpigpi
    edited 8:16PM
    Call rptDataSource.Dataset.DisableControls
  • edited 8:16PM
    Hi again
    after calling DisableControls result is same!
  • edited December 2014
    Okay, I made a little bit changes in my code, I added an ADOQuery to frmReport form and assigned it to frxDatabase dataset property, when I call ShowFastReport procedure I fill the SQL property of the ADOQuery to execute the stored procedure. the final code is as bellow:
    procedure ShowFastReport(ReportParam: TReportParams; ReportName, QueryStr: string);
    var
      VIdx,
      Count: integer;
      tmpComponent,
      tmpComponent1: TfrxComponent;
      Database : TfrxADODatabase;
      Query: TfrxADOQuery;
      Variable: TfrxVariable;
      tmp: string;
    begin
      frmWaiting.ShowWaitingForm(GetMessageBody(541), GetMessageBody(141));
      frmReport.frxReport1.Clear;
      frmReport.frxReport1.LoadFromFile(ReportName);
      if Software.DecimalQTY = 2 then
        SetCrParam(ReportParam, 'DisplayFormat', '#,##0.00;(#,##0.00);-;-')
      else
        SetCrParam(ReportParam, 'DisplayFormat', '#,##0;(#,##0);-;-');
      SetCrParam(ReportParam, 'CustomerName', ShowCompanyName);
      SetCrParam(ReportParam, 'ReportName', ExtractFileName(ReportName));
      SetCrParam(ReportParam, 'UserName', CRMUser.UserName);
      SetCrParam(ReportParam, 'ReportDate', GetMessageBody(286) + CRMUser.GetDate);
      SetCrParam(ReportParam, 'WebURL', 'RayaCRM3: www.rayacrm.com');
      for Count := 1 to frmReport.frxReport1.Variables.Count do
      begin
        if ReportParam[Count, 1] <> 'nil' then
        begin
          VIdx := frmReport.frxReport1.Variables.IndexOf(ReportParam[Count, 1]);
          if VIdx <> -1 then
          begin
            Variable := frmReport.frxReport1.Variables.Items[VIdx];
            Variable.Value :=  QuotedStr(ReportParam[Count, 2]) ;
          end;
        end;
      end;
    
      frmReport.ADOQuery1.DisableControls;
    
      frmReport.ADOQuery1.Close;
      frmReport.ADOQuery1.SQL.Text := QueryStr;
      frmReport.ADOQuery1.Active := true;
    
      frmReport.frxReport1.ShowReport();
    
      frmReport.ADOQuery1.EnableControls;
      frmWaiting.HideWaitingForm;
    end;
    

    when user click on the Show Report button this code will call:
    procedure TUserProjects.btnPrint1Click(Sender: TObject);
    var
      QueryString,
      ReportName: string;
    begin
      if not CRMUser.HaveThisRight ((sender as TBitBtn).Tag, true) then
        Exit;
      QueryString := ' Exec sp_GetUserAllProjectsnp  @UserCode = ' + IntToStr(CRMUser.UserCode) +
                     ',@Keyword = ' + QuotedStr(Search.Text);
      ReportName := Software.ServerPath + '\FReports\UserProjectsNew.fr3';
      EmptyReportParams(CrParams);
      SetCrParam(CrParams, 'UserCaption', GetMessageBody(666));
      SetCrParam(CrParams, 'ReportCaption', GetMessageBody(288));
      SetCrParam(CrParams, 'RowCaption', GetMessageBody(314));
      SetCrParam(CrParams, 'LastDate', GetMessageBody(293));
      SetCrParam(CrParams, 'ProjectLabel', GetMessageBody(291));
      SetCrParam(CrParams, 'ProjectStep', GetMessageBody(290));
      SetCrParam(CrParams, 'ProjectName', GetMessageBody(40));
      SetCrParam(CrParams, 'Target', CRMUser.UserName);
      SetCrParam(CrParams, 'RequestDate', GetMessageBody(365));
      SetCrParam(CrParams, 'Reason', GetMessageBody(375));
    
      ShowFastReport(CrParams, ReportName, QueryString);
    end;
    

    As you see in the ShowFastReport I called DisableControls before calling ShowReport and after that I called EnableControls. but the result is same! [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I really confused! I think the coding has no problem, If I enter ADOQuery1.SQL.Text manually and run the preview from report designer in generate the reports really fast, but when I set SQL.Text property in runtime and open the query it does not work as expected. I attachec 3 pictures of the frxReport1, frxDatabase and ADOQuery1 properties. If you gays want to see the code and check it yourself you can connect my PC using TeamViewer. thanks in advance[/img]
  • edited 8:16PM
    If you are sure that frmReport.frxReport1.ShowReport() is taking so long then you can try to decouple a little.
    Put a TDataSetProvider and a TClientDataSet between ADOQuery1 and frxDBDataSet1
    ADOQuery1->DataSetProvider1->ClientDataSet1->frxDBDataSet1

    And you will open ClientDataSet1
  • edited 8:16PM
    Peta wrote: »
    If you are sure that frmReport.frxReport1.ShowReport() is taking so long then you can try to decouple a little.
    Put a TDataSetProvider and a TClientDataSet between ADOQuery1 and frxDBDataSet1
    ADOQuery1->DataSetProvider1->ClientDataSet1->frxDBDataSet1

    And you will open ClientDataSet1

    thanks for the reply

    I will try it and let you know the result. I also decided to capture my screen and upload here to see how much slow it is!
  • edited December 2014
    Hi everybody
    I tried different ways and methods to resolve the problem but it seems there is something out of my control! With current method described on my last post (#7) it works great on windows 8 just 2-3 seconds to make the report but on windows 7 we have speed problem! 10-15 minutes to generate same report!
    any suggestion?
  • edited 8:16PM
    Do we have fast report support experts here in this forum or we are on our own?!
  • gpigpi
    edited 8:16PM
    Can you create a small demo project with problem based on standart Delphi's components and local database like MS Access?
  • edited 8:16PM
    Dear gpi
    Thank you for your reply,
    Creating a small project on Access database using standard Delphi components will completely change the situation I am now involved with, with current database and components I've already used, program works fine on Windows 8 but on windows 7 it has speed problem! in the design reporter also there is no problem. even in windows 7, If i click on preview it generate report really quick(design time).
    If you don't mind you can check the problem using team viewer.
  • edited 8:16PM
    Hi
    For whom, they may face to similar problem, After upgrading to Windows 7 64bit the problem solved.

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.