Recent

Author Topic: howto loadfromdb ?  (Read 2648 times)

mirce.vladimirov

  • Sr. Member
  • ****
  • Posts: 256
howto loadfromdb ?
« on: December 31, 2014, 08:19:21 am »
So far I created many reports using Lazreport and all of these reports are stored in a *.lrf file on the working directory of the application that calls them.
But I think that it would be veeery good to store my *.lrf files into a database and do a frreport1.loadfromdb from within a program.
I know there is such a thing but i dont know how to use it,  how to store a report into a DB and how to load it from there.

JZS

  • Full Member
  • ***
  • Posts: 194
Re: howto loadfromdb ?
« Reply #1 on: December 31, 2014, 09:23:36 am »
1. Have your design ready and saved, for instance, as "YourReport.lrf".
2. Have a Dataset configured to read/write to your database where you intend to keep the forms in a blob field. Make sure to have at least two fields, first is Integer and the second is the blob where your report goes in.
3. For the first and one time only, you do:
Code: [Select]
  frReport1.LoadFromFile('YourReport.lrf');
  frReport1.SaveToDB(EditableDataSet, FieldNumber);
and thereafter you comment them out and use:
Code: [Select]
  //frReport1.LoadFromFile('YourReport.lrf');
  //frReport1.SaveToDB(EditableDataSet, FieldNumber);
  frReport1.LoadFromDB(DataSet, FieldNumber);


PS: FieldNumber is the first Field in your dataset and it should be an integer, where the values stored will be compared to find match, when found it reads the very second field of the matched record.
Same concept when loading.

For more details, look at SaveToDB/LoadFromDB at the source (Unit: LR_Class).

Edit:
Whenever you update the design "lrf" make sure to call SaveToDB once more to update your fields.
« Last Edit: December 31, 2014, 09:27:45 am by JZS »
I use recent stable release

 

TinyPortal © 2005-2018