Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Template.LoadFromdatabase - Access denied

edited May 2013 in General
Hi

I have a datamodule containing datasets/sources etc and a TppReport.
The report template is saved in a table, and before printing the report
is loaded by invoking Template.LoadFromdatabase.

My datamodule is used in two projects.
One normal delphi application and in a web-service application (dll).

When using the datamodule from the normal delphi application everythning
works fine, but when used from the webservice LoadFromdatabase generates
an "Access is denied" error.

Any ideas ? Some temporary file used when loading ?

Regards
René Laursen/SSV

Comments

  • edited May 2013
    A Web Service will typically have two big differences from an application.

    1. Web apps tend to be multi-threaded. For the DataModule, make sure you
    have a database connection component and the datasets use that connection.

    2. Web apps tend to run under a specify Windows user account. Often this
    account has restricted security.



    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2013
    2. Web apps tend to run under a specify Windows user account. Often this

    I think this is the problem. But can you give me a hint to
    why/what/where LoadFromDatabase may offend the restrictions ?

    René
    (Sorry for my accidental direct mail)
  • edited May 2013

    What database engine and data access components are you using? Each web
    service request should create a separate instance of the TDataModule. The
    TDataModule should provide a thread-safe container for the processing to
    execute. For Database Access this means the TDataModule should contain a
    Database connection components, dataset, etc. And of course the TppReport
    and TppDBPipeline (or if using DADE then don't worry about anything). Check
    out the RBuilder help topic for TppReport. BackgroundPrintSettings for a
    discussion of thread safety.

    ReportBuilder uses standard TDataSet methods for all data access.RB Server
    Edition includes a multi-threaded server that can load reports from
    database, so we know it works.

    If you think LoadFromDatabase is the issue, then try some simple incremental
    test. Try a test with a report that is not loaded from database - just a
    static report. Perhaps start with a blank report, then test with a report
    with one label, then add database access as a separate test - add data
    access components and a DBText for the report. Then later test load from
    database with the above.



    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2013
    Hi
    I finally came back to this issue and found what was the problem.

    The problem is some nonsense code in
    procedure TppTemplate.LoadFromSource(aSaveToType: TppSaveToType);
    (Rebortbuilder vers 12.02)

    ...
    if (aSaveToType = stDatabase) then
    {load template from datapipeline}
    try
    if
    (lDataPipeline.GetFieldDataType(FDatabaseSettings.TemplateField) in
    [dtMemo, dtString]) then
    begin

    // get field value as string
    lsTemplate :=
    lDataPipeline.GetFieldAsString(FDatabaseSettings.TemplateField);

    (* commented this section out. 1) lsFilename is undefined. 2) Anyway it
    does not give any sense to load from file when savetotype is stdatabase
    if FileExists(lsFileName) then
    lLoadStream.LoadFromFile(lsFileName)
    else
    *)
    begin
    ...

    Best Regards
    René

    Den 24-05-2013 13:56, René Laursen - SSV skrev:
  • edited September 2013

    The code was fixed Nov 19, 2010 and is included in RB 12.04 and beyond
    (below is a copy of the correction). RB 12.05, was the last produced release
    for RB 12.x - I recommend updating to that version.

    Going forward I recommend upgrading to RB 15..


    if (lDataPipeline.GetFieldDataType(FDatabaseSettings.TemplateField) in
    [dtMemo, dtString]) then
    begin

    // get field value as string
    lsTemplate :=
    lDataPipeline.GetFieldAsString(FDatabaseSettings.TemplateField);

    // check whether template field contains a file name reference
    if FileExists(lsTemplate) then
    lLoadStream.LoadFromFile(lsTemplate)
    else



    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.