SaveToStream

Hi

I am using DBISam and Fast Report 2.4.

Has anybody got an example for me how to use SaveToStream. I need to be able to do the following:

1. Create a new report

2. Change an existing report

3. Save it to a database if changed asked if it must be saved

Any help will be appreciated.

Regards

Petrus

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 1:18PM
    saving loading from blob stream or field
    1 table to store report must have
    ist field must be repid integer
    2nd field blob
    any other fields come after these.

    you must hook into the designer's onsave and onload events
    and write your own custom dialog to handle what you must do to position yourself within the table storing the reports.
    depending upon db engine you may be able to use save to blob or save to stream.
    here is a sample
    the user has selected a choice for saving a new report in a blob

    procedure TForm1.BtnDsgnClick(Sender: TObject);
    begin
    frdesigner1.opendir := wpath +'Reports'; //set base dir for open dialog.
    frdesigner1.savedir := wpath +'Reports'; // same for save
    frdesigner1.TemplateDir := wpath+'rpttmplt';// same for template dir



    case optgrp1.itemindex of
    //other entries
    5:
    begin // use custom dialog to save to db blob
    frreport1.clear;
    frreport1.Dictionary.Clear;
    frReport1.Dictionary.DisabledDatasets.Add('repdm.table2');
    frreport1.title := 'Untitled';
    frdesigner1.OnLoadReport := nil; // use normal dialog
    frdesigner1.onsavereport := frDesigner1SaveReport;// connect handler
    blrepsaved := false;
    frreport1.designreport;
    if not blrepsaved then
    begin
    showmessage('Report was not saved'+#13#10+'all editing has been lost');
    end;
    end;

    procedure TForm1.frDesigner1SaveReport(Report: TfrReport;
    var ReportName: String; SaveAs: Boolean; var Saved: Boolean);
    begin
    if SaveAs then
    with saverepdlg do
    begin
    Saved := ShowModal = mrOk;
    if Saved and not bloverwrite then
    begin
    repdm.TblRepdef.active := true;
    repdm.tblrepdef.edit;
    repdm.tblrepdef.insert;
    repdm.TblRepdefrepid.value := intrepno +1;
    repdm.TblRepdefDescription.Value := strrepname;
    Report.SaveToBlobField(repdm.tblrepdefrepdef);
    ReportName := strrepname;
    repdm.TblRepdef.Post;
    form1.blrepsaved := true;
    end;// end ifsavedand not overwrite
    if saved and bloverwrite then
    begin
    repdm.TblRepdef.active := true;
    repdm.TblRepdef.FindKey([intrepno]);
    repdm.TblRepdef.edit;
    repdm.tblrepdefrepdef.clear;
    Report.SaveToBlobField(repdm.tblrepdefrepdef);
    repdm.TblRepdefDescription.Value := strrepname;
    repdm.TblRepdef.Post;
    form1.blrepsaved := true;
    end;
    end
    else
    // Report.SaveToBlobField(...);
    showmessage('save cancelled');
    repdm.TblRepdef.Active := false;
    end; // endpro

    should give you basic idea
    ;)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.