Home General

ReportPreview and ThreadedCache best practices

After switching to Delphi Tokyo (I've tried and found no difference between using RB 18 or 19) we are experiencing a lot more instances of the preview hanging. This can be solved by setting SinglePageOnly as per your suggestions in many posts.

I cannot say that I have read all the posts concerning this problem, but I have read a lot. I have yet to find a post that goes into what should be avoided, I apologize if there are one, and I just didn't find it. The best I've found is this: http://www.digital-metaphors.com/forums/discussion/7432/reportbuilder-hanging . Here I found that you should not access the report or data components from the main thread. Am I correct in assuming that this means that I am not to open detail querys in a main querys afterscroll? Am I allowed to access a report component, say, in a beforegenerate event.

Could you please elaborate on the pitfalls?

Comments

  • Hi Johnny,

    The scrollable page preview generates pages in a background thread. This requires thread-safe data access. In Delphi (and Windows) visual controls can only execute in the main thread.

    Simplest solution is to use the RB Data workspace to build and link the queries. Use a separate Data Connection object for the reports (ex. FDConnection for FireDAC). Use the Report.Parameters[ ] feature to handle auto search. RB takes care of everything.

    RB can open the datasets and traverse the data. To implement master/detail use RB linking. Never manipulate the datasets while the report is generating (i.e. AfterScroll or other).

    Do not share datasets with reports and visual controls.

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • Thank you for your swift reply!

    I am not sure that we can use the data workspace as we have forms with multiple reports using the same underlying datasets. However I was going to give a shot, but using e.g. "RBuilder\Delphi 10.2 Tokyo\Tutorials\Complete\I. Reports\08. Master - Detail - Detail Report" prompts me for credentials? I can't find them anywhere.

    Best regards,
    Johnny
  • Hi Johnny,

    - For credentials, leave empty and press Ok. The report demos and tutorials are designed for any RB Edition and as such do not use the RB Data workspace (DADE).

    - The end-user demos and tutorials are included with RB Pro and Enterprise. They use the RB Data workspace. The Dev Guide covers DADE and there are database specific demos installed to Demos\End-user Databases. These demos also show the end-user components, but you can ignore that for your purposes.

    - Using the Data workspace, you can build and link the queries in seconds. Each report definition will contain its own queries.

    - The best architecture is to either create a separate Form/DataModule for each report. Or create a single Form/DataModule that can load report definitions stored to .rtm files or database. When the application needs to run a report, create an instance of the 'report module' and call a method to generate the report.

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
Sign In or Register to comment.