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 10:28PM
    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