Home End User

Problem while saving a .rtm file to database.

edited December 2002 in End User
Dear Mr, Mrs,

I have got a problem. I have a few reports in .rtm format saved. I want to
read them in Delphi and post them in the database in a blob field.

This seems to work fine. But when I open the report from the table, I get
the following error:

Project MsgSrvReportGenerator.exe raised exception class
EInvalidTemplateError with Message 'Invalid Template Format'. Process
stopped.

Below you will find the sourcecode I have used to set the reports from .rtm
to table. I use the LoadFromFile and the SaveToDatabase. Before I do this, I
change the settings of the report. The property
Template.DataBaseSettings.Format is set to ftBinary. For the rtm file and
table blob report. Is there still some property that I still need to set? Or
do I need to do something else?

Can someone please help me out?

Thanks in advance and best regards,


Mischa E.J. Hoogendoorn

//Read from file.
Template.DatabaseSettings.DataPipeline := NIL;
Template.DatabaseSettings.NameField := '';
Template.DatabaseSettings.TemplateField:= '';
Template.FileName :=
IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) +
'Reports\' + aFileName[i];

Template.LoadFromFile;
//Prepaire saving to DB.
Template.DatabaseSettings.DataPipeline := DmMain.ppReportTool;
Template.DatabaseSettings.NameField := 'Description';
Template.DatabaseSettings.TemplateField:= 'ReportFile';
//Saving report in the table.
DMMain.tblReportTool.Insert;
DMMain.tblReportTool.FieldByName('Description').AsString :=
aDescription[i];
DMMain.tblReportTool.FieldByName('CharmedReport').AsBoolean :=
True;
DMMain.tblReportTool.FieldByName('PublicReport').AsBoolean :=
False;
DMMain.tblReportTool.FieldByName('PrivateReport').AsBoolean :=
False;
Template.SaveToDatabase;
DMMain.tblReportTool.Post;

Comments

  • edited December 2002
    The only place we raise this error is if the template can't be read from the
    stream. Try creating a new template from scratch and save it to the
    database. What is the field type and database that you are saving to? What
    are the Template.DatabaseSettings when you load from the database when you
    get the error?


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    Thanks Jim,

    I had almost evreything done the right way, you made me find it. I had
    forgotten to set one property:

    Template.DatabaseSettings.Name := aDescription[i];

    This resulted in a empty blob field, and when you are trying to get a report
    out of an empty blob field, you will get the error descripted.

    Thanks for you help and a happy newyear to all over there!


    Mischa E.J. Hoogendoorn

This discussion has been closed.