creating frxDBDataSets at runtime

edited September 2017 in FastReport VCL 5
Newbie here. I'm using the demo in EmbedDesigner to build an app to allow another worker here (without much technical ability) the ability to build simple reports.

I'm trying to create a bunch of TfrxDBDataSets and associated TTables on the fly at runtime. The following code is good enough to allow the user to lay out a report with fields from selected tables, but when Preview is attempted an error is thrown:

  if FindFirst('c:\data\*.dbf', faAnyFile, sr) = 0 then
  begin
    repeat
        with TfrxDBDataset.Create(self) do
        begin
         Name:='FRTable' + ChangeFileExt(ExtractFileName(sr.Name),'');
         Dataset:=TTable.Create(self);
         Dataset.Name:='Table' + ChangeFileExt(ExtractFileName(sr.Name),'');
         TTable(Dataset).DatabaseName:='c:\data\';
         TTable(DataSet).TableName:=ChangeFileExt(ExtractFileName(sr.Name),'');
         TTable(DataSet).TableType:=ttDBase;
         UserName:=ChangeFileExt(ExtractFileName(sr.Name),'');
        end;
    until FindNext(sr) <> 0;
    FindClose(sr);
I'm sure its something simple, but as a newbie I don't see it.

Comments

  • PolomintPolomint Australia
    edited 2:22PM
    Dave F wrote: »
    but when Preview is attempted an error is thrown
    What is the nature of the "error" Dave? Short of recreating your programme, it's a bit hard to tell >
  • edited 2:22PM
    This particular version of my code does not throw a specific error. Not sure why either. I'm running it from the IDE yet it is not trapped properly.
    Polomint wrote: »
    Polomint wrote: »
    but when Preview is attempted an error is thrown
    What is the nature of the "error" Dave? Short of recreating your programme, it's a bit hard to tell >
  • gpigpi
    edited 2:22PM
    Create small demo project and attach it here
  • edited 2:22PM
    Attached.
    gpi wrote: »
    Create small demo project and attach it here
  • edited 2:22PM
    Any help?
  • gpigpi
    edited 2:22PM
    remove frxDBDataset1 from form
  • edited 2:22PM
    That cleaned it up. What's going on here?
    gpi wrote: »
    remove frxDBDataset1 from form

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.