Home General

Error in LoadFromDatabase after 50 or so calls

I have and issue where after 50 or so calls to build and then export to PDF a report I get the error system error code: 1400

My code Creates a datamodule with the PPReport component and all pipes on the datamodule form, sets the pipes, loads the reportxxx.RTM from a database table, then sets the output to pdf and prints. Program then closes the database connection and frees the datamodule.

The program is a delphi ISAPI web dll. built on delphi 10.4.2 using intraweb 15.2.5

It works great for about 50 or so times then always get this error.
I do check that the database connection is good and that the query to get the report returns the correct record.


ppreport1.Template.DatabaseSettings.Name:=Rptname
ppreport1.Template.DatabaseSettings.NameField:='REPORT_NAME'
ppreport1.Template.DatabaseSettings.TemplateField:='REPORT_FILE'
ppreport1.Template.LoadFromDatabase
Error in LoadReport Error:System Error. Code: 1400.

Comments

  • I am running Report builder 20.04 build 84
    I create Datamodule using example code below.
    If building for ISAPI should I create the reports datamodule differently?
    I do not have issue with VCL app.

    Function BuildReport:string;
    Var
    rptdata :rptdm ;
    begin
    rptdata:=Trptdm.create(nil);
    Try
    // load report, set datapipes,set output to PDF and print
    ....
    Finally
    RPtdata.connect.Close;
    RPtdata.Free;
    End;
    end;
  • Hi Bill,

    - Here is a discussion of this issue encountered by another developer

    http://www.digital-metaphors.com/forums/discussion/21210/window-handle-error-on-loadfromdatabase

    -The DataModule should be the Owner for the database connection object, data access objects, data pipelines, report etc. It must be created/freed in the same thread

    - I also recommend calling

    // initialize COM for this thread
    ActiveX.CoInitialize(nil);

    try
    ... process the request

    finally
    // unitialize COM for this thread
    ActiveX.ConUnitialize;






    Best regards,

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

    The Code that genrates the PDF run from an AsyncButtonClick and is not run in a thread and all the compoents including the ado connection component are on the datamodule. I just pass in the connection string, report name, sql where clause.
    What units do I need to support ActiveX.CoInitialize(nil) statment.
    Would Adding the ActiveX.CoInitialize(nil) have anything to do with invalid window handle?


    I would be happy to send the code for you review
  • Hi Bill,

    ActiveX is the unit, the code is using the UnitName.FunctionName notation. in modern Delphi it is Winapi.ActiveX. CoInitialize/CoUninitialize are Windows API COM functions.

    You definitely need to add those calls. I do not recall whether the omission specifically results in invalid windows handle errors.

    I don't have experience with IntraWeb, but often Async routines are called within threads - its jus that you don't deal with the thread object directly. If you have a Web app that is not using threads, it would be very slow. When using Delphi Web Broker, all the actions are executed within threads.

    Best regards,

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