I have got "script error: unknown type TDataset", someone help me please...

edited 9:21PM in FastReport 4.0

I wrote the following procedure in "code" page:

procedure DetailData1OnMasterDetail(Sender: TfrxComponent);
var
Dh: Integer;
ds1, ds2, ds3: TDataset;
begin
ds1 := TfrxDBDataSet(MasterData1.DataSet).DataSet;
ds2 := TfrxDBDataSet(DetailData1.DataSet).DataSet;
ds3 := TfrxDBDataSet(Report.GetDataSet('rpdsSk')).DataSet;
..........

It works fine when designing, but if I try to preview the report page at runtime in my app, I got the following exception:

Script error at 9:31: unknown type 'TDataset'.

and I found that the exception was thrown at here:

function TfsILParser.FindClass(const TypeName: String): TfsClassVariable;
begin
Result := FProgram.FindClass(TypeName);
if Result = nil then
raise Exception.Create(SUnknownType + '''' + TypeName + '''');
end;

I am so so sad about this......any help would be greatly appreciated, thanks a lot.......

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 9:21PM
    ds1, ds2, ds3: TDataset;
    should be
    ds1, ds2, ds3: TfrxdbDataset;
  • edited 9:21PM
    gordk wrote: »
    ds1, ds2, ds3: TDataset;
    should be
    ds1, ds2, ds3: TfrxdbDataset;

    It does work, I still got error with message "Scripts error : Unknown type "TfrxDataset"......

    Thanks a lot.
  • gordkgordk St.Catherines On. Canada.
    edited 9:21PM
    here is a sample
    before begin end. block of report code
    var
    i: Integer;
    ds: TfrxDataSet;
    list: TStringList;

    this may be used in any procedure
    ds := Report.GetDataset('frxDBDataSet1'); // the username of the ds
    list := TStringList.Create;
    ds.GetFieldList(list);
    for i := 0 to list.Count - 1 do
    somevar := ds.Value[list]; // get field value by its name

Leave a Comment