Recent

Author Topic: How to Load lazreport from blob  (Read 1049 times)

sydenis

  • New Member
  • *
  • Posts: 23
How to Load lazreport from blob
« on: May 10, 2021, 01:48:12 pm »
ubuntu 20.04 + lazarus 2.0.12
I am trying to load report from my SQLite db:

Code: Pascal  [Select][+][-]
  1.   fStream := TMemoryStream.Create;
  2.  (fQuery.FieldByName('blob') as TBlobField).SaveToStream(fStream);
  3.   fQuery.Close;
  4.   fStream.Position := 0;
  5.  
  6.   fStream.SaveToFile('blob.lrf');  //for cheking
  7.   fStream.Position := 0;
  8.  
  9.   with frReport do
  10.   begin
  11.     LoadFromStream(fStream);
  12.     ShowReport;
  13.   end;      
         
 
I get an exception: Invalid binary report: Invalid report version (60).

When I take my control file 'blob.lrf' (see above) and do

Code: Pascal  [Select][+][-]
  1.   with frReport do
  2.   begin
  3.     LoadFromFile('blob.lrf');
  4.     ShowReport;
  5.   end;
 
all is good... (

I try to use frReport.LoadFromDB but the problem persist.
So, where is the mistake. How to load report from db blob?

see report file in attachment

korba812

  • Full Member
  • ***
  • Posts: 178
Re: How to Load lazreport from blob
« Reply #1 on: May 10, 2021, 02:54:03 pm »
Use "LoadFromXMLStream(fStream)" instead of "LoadFromStream(fStream)". LoadFromStream is for prepared binary report.

sydenis

  • New Member
  • *
  • Posts: 23
Re: How to Load lazreport from blob
« Reply #2 on: May 10, 2021, 08:18:42 pm »
Thank you very much! Works fine.

 

TinyPortal © 2005-2018