Home General

What's the deal with templates?

edited August 2001 in General
Hi.

Love the idea of templates, particularly the way they can be saved to a
database table. However, I'm a little confused about how to implement this.
If I outline what I'm doing maybe I can be corrected along the way if I go
wrong. Say I create a report at design time and have it set up just how I
want. I then set up the template properties to point to a table in my ms
sql server database and set the report option to saveastemplate. Calling
FileSave from the report designer then does indeed appear to save it to my
database table. However, it still exists in the DFM file of the form the
component is on. So I assume I have to then delete the report component to
remove it from the DFM. Great, so I now have a report saved to the database
rather than increasing the size of my exe.

But..... what if I then decide I want to change the original definition in
some way. The only way I can see to do this is by either adding a report
component to a form and then setting all it's properties appropriately
causing it to be loaded into the component from the database, or using the
designer component and changing it at runtime. Now is this the way it is
supposed to work? Isn't there a way to create a report and store it in the
database not the exe yet still be able to alter it as required easily?
Maybe I'm getting completely the wrong end of the stick here, could some
please enlighten me.

The other point I don't understand it that the datapipeline for the report
still has to exist on a form in the application, so the report is never
totally separate from the application. So if I release my exe and need to
change a report I can change the layout but not touch the query behind it?
Is there a way to include the database settings within the saved report? I
tried to use the following code but keep getting access violations.

procedure TSiteForm.Button1Click(Sender: TObject);
begin
ppReport1:=TppReport.Create(nil);
try
ppReport1.Template.DatabaseSettings.Name := 'Site Report';

ppReport1.Template.DatabaseSettings.Datapipeline:=ReportsDM.ReportsPipeline;
ppReport1.Template.DatabaseSettings.Namefield:='NAME';
ppReport1.Template.DatabaseSettings.Templatefield:='TEMPLATE';
ppReport1.Template.LoadFromDatabase; // avs occur here.
ppReport1.Print;
finally
ppReport1.Free;
end;
end;

What am I missing?

TIA.

John.

--
I don't like spammers so send your spam to
abuse@hotmail.com

Comments

  • edited August 2001
    Correct, the report component on the form, when it is saved, will stream
    down the objects that are in the report into the dfm. The form owns the
    report, and the report owns the components.

    You don't have to use datapipeline components on a form, as this has its
    limitations. DADE, our visual data access environment, stores the entire
    data defintion (queries which appear as visual datapipelines) inside the
    report template. The data definiton (report data module) can be saved as a
    dtm and this dtm file can be unloaded and loaded into DADE, just as an
    entire report template can be loaded into a report. Now, if you change the
    query for a report, only the template needs to be updated in the user's
    database, not the exe.

    Since you're going to be using templates, then as far as calculations go,
    there is RAP, which stores all of the event handlers for a report, inside of
    the report template as well. If you decide to change a calculation in an
    event handler for a report, then you won't have to recompile the exe and
    redistibute it. You'll only need to update the user's database with the new
    version of the template.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2001

  • edited August 2001
    It is possible to replace the datamodule in the report. You can save the
    dtm in the database, just like an rtm. From the report explorer, a user can
    create a new report, then go into DADE for that report, and import a dtm so
    the queries won't have to be recreated.

    To modify a report template that exists in the database, it will have to be
    loaded into a report component and visually edited and saved back down to
    the database. Or, if the report template format property is set to ASCII,
    you can load the template as text into a stringlist and edit the report
    definition, just like a dfm file as text.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.