Runtime resolution of Datasets using TfrxDBDataset
Mark Elder
SD, USA
Hello,
I am trying to make sure I understand how data added to a report, using the TfrxDBDataset connector object, is resolved at runtime. From looking into the saved report file (*.fr3) I don't see any reference the module name the component came from, just the component name itself.
Just to see what happened I added a TfrxDBDataset to different modules but left the name the same. Both were visible to the report and it allowed me to add both to the report. This seems like it could really cause problems.
http://stackoverflow.com/questions/6760750...dules-in-delphi
I am letting end users create custom reports and I am concerned about two items. 1) That they connect to the right data at runtime. 2) That they don't see "extra" data during design time from other open DataModules. If a different form is open at the same time and happens to have frxDBDataset objects I don't want the user to select them since they may or may not be open the next time they run the report.
I'm considering adding the following code before a report is run or designed. It seems like I could then disable the "Report->Data" menu item to make sure that user's can't see and select a different DataSet that may not be available run the report is run.
Thanks,
Mark
I am trying to make sure I understand how data added to a report, using the TfrxDBDataset connector object, is resolved at runtime. From looking into the saved report file (*.fr3) I don't see any reference the module name the component came from, just the component name itself.
Just to see what happened I added a TfrxDBDataset to different modules but left the name the same. Both were visible to the report and it allowed me to add both to the report. This seems like it could really cause problems.
http://stackoverflow.com/questions/6760750...dules-in-delphi
I am letting end users create custom reports and I am concerned about two items. 1) That they connect to the right data at runtime. 2) That they don't see "extra" data during design time from other open DataModules. If a different form is open at the same time and happens to have frxDBDataset objects I don't want the user to select them since they may or may not be open the next time they run the report.
I'm considering adding the following code before a report is run or designed. It seems like I could then disable the "Report->Data" menu item to make sure that user's can't see and select a different DataSet that may not be available run the report is run.
procedure TMgrFastReportPreviewForm.Configure(ReportData: TDataModule);
var
i: Integer;
begin
for i := 0 to ReportData.ComponentCount -1 do
begin
if ReportData.Components[i] is TfrxDataSet then
begin
frxReport.DataSets.Add(ReportData.Components[i] as TfrxDataSet);
end;
end;
end;
Am I thinking about this right? I really like the ability to fill the datasets in my Delphi code and pass them to the report. I just want to make sure it all continues to work as I add more Forms and DataModules to my program.Thanks,
Mark