changing dataset at runtime?

edited February 2004 in FastReport 2.xx VCL
Can anyone tell me how to change the dataset on a report at runtime? When I execute the following, I get undefined symbols on the database fields in the report.
procedure runreport(sql:string; repname:string);
var
     frDS: TfrDBDataSet;
     fr : TfrReport;
     repCDS : TClientDataSet;
begin
     repCDS := initcds; // function to create and initialise with soap info
     repCDS.CommandText := sql;
     repCDS.open;

     frDS := TfrDBDataSet.create(repCDS);
     frDS.DataSet := repCDS;
     frDS.name := 'frDBDataSet1';

     fr := TfrReport.create(repCDS);
     fr.loadfromfile(repname);
     fr.Dataset := frDS;

     (* something here to setup the report for the dataset - find what dataset used 
         and replace*)

     fr.preparereport;
     fr.savepreparedreport(repname+'.frp');
end;

Comments

  • edited 8:13PM
    I found that by adding to fr.dictionary.fieldaliases I could get the undefined symbols to match up.

    before the preparereport in my original message I added
    fr.dictionary.fieldaliases.insert(0,'repcds');
    fr.dictionary.fieldaliases.value[0] := 'originalname';
    

    now all I have to figure out is what are the original dataset names used in the report
    when designed.

    klint.

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.