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

edited 11: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 11:21PM
    ds1, ds2, ds3: TDataset;
    should be
    ds1, ds2, ds3: TfrxdbDataset;
  • edited 11: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 11: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

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.