Window Handle error on LoadFromDatabase

Hi.

Delphi 10, RB 19.04, Intraweb application. i have this error

System Error. Code: 1400. Invalid WIndow handle.

on this code:
repDesigner: TPPReport;

repDesigner.Template.DatabaseSettings.Name := sqlCustomReportsREPORT_NAME.AsString;
repDesigner.Template.LoadFromDatabase; // this line giving exception!

Since i noticed that "sometimes" the error was not occuring I had the idea to try with this "odd solution":

repDesigner.Template.DatabaseSettings.Name := sqlCustomReportsREPORT_NAME.AsString;
try
repDesigner.Template.LoadFromDatabase;
except
repDesigner.Template.LoadFromDatabase;
end;

The above "horrible" code somehow works and likely bypasses a RB issue. I foudn also this discussion:
http://www.digital-metaphors.com/forums/discussion/9378/iw-richtext-template-loadformdatabase-invalid-window-handle

This problem occurs only on some data, do you have any hintor comment?

I amnowusing the "starnge" workaround above to make my application work, but I do not like it at all. For sure it does not harm much, in the worst scenario i raise 2 identical exceptions.

Thanks for reading!

Comments

  • Hi Francesco,

    For web/threaded apps, I recommend using a DataModule containing the TppReport and data connection component. Call it TMyReportModule. To handle a web request, create an instance of TMyReportModule and call a public method, like TMyReportModule.GeneratePDF(some params here) and free the instance.


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • I reply just to close the ticket.

    I confirm the problem has been solved making sure each thread has an instance, in fact inmy intraweb application imake sure each form or datamodule has an instance per session, this is done manually. Somehow the datamodule containing the ppReport was not treated as the others (since it is done manually as i said), now it is fixed. Thanks.
Sign In or Register to comment.