Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Report will only show design time data

edited June 2003 in General
I have a TppReport that only seems to show the design time data.

At design time I have formatted the report and at runtime I am dynamically
changing the parameters and it has no effect.

Here are the specifics:

The Delphi form has a TppReport and associated TppDBPipeline on it.
The TppDBPipeline has an associated TDatasource that is attached to a
TADOStoredProc.

At design time everything is fine. At runtime I am basically replacing the
TADOStoredProc with a dataset that gets executed prior to printing the
report and then printing the report. Everything about the report other than
the newly assigned dataset is the same.

I am stepping though it and can verify that all the parameters are what they
should be, the TADOStoredProc is executing right and returning a different
dataset each time.

Here is the code that sets it up:

procedure TfrmDistributors.btnPrintReportClick(Sender: TObject);
var
SP : TADOStoredProc;
begin
try
frmReports := TfrmReports.Create(nil);
SP := TADOStoredProc.Create(nil);
try
with TADOStoredProc(SP) do
begin
Close;
Connection := DM.ADOConnection;
ProcedureName := 'sp_rptGetDistributorOrders';
Parameters.Refresh;
Parameters.ParamByName('@Distributor_ID').Value :=

dsDistributorListing.Dataset.FieldByName('Distributor_ID').AsInteger;

if (cbOrderType.ItemIndex = 0) then
Parameters.ParamByName('@WholesaleOnly').Value := 1
else
Parameters.ParamByName('@WholesaleOnly').Value := 0


Parameters.ParamByName('@Start_Date').Value :=
deOrdersStartDate.Text;
Parameters.ParamByName('@End_Date').Value := deOrdersEndDate.Text;
Open;
end;

frmReports.ShowDistributorOrders(SP, ExtractFilePath(ParamStr(0)) +
'Reports\Standard\DistributorOrdersByDate.rtm');

except
on E:Exception do
begin
frmMain.ShowDialog(E.Message, dtError, Self.Handle);
end;
end
finally
FreeAndNil(SP);
end;
end;


Here is the method of the report form that gets called:

procedure TfrmReports.ShowDistributorOrders(OrderDataset: TDataset;
TemplateName: string);
begin
dsRuntime.Dataset.Close;
dsRuntime.Dataset := OrderDataset;
rptRuntime.Template.Filename := TemplateName;
rptRuntime.Template.LoadFromFile;
rptRuntime.Reset;
rptRuntime.Print;
end;


I am completely stumped here. What am I doing wrong?
Thanks,


--
Reid Roman
Future Generation Software
http://www.fgsoft.com

Comments

  • edited June 2003
    Hi Reid,

    After you call Report.Template.LoadFromFile, assign the Report.DataPipeline
    property to the pipeline that you have assinged dsRunTime to. The reason is
    the template saves the datapipeline name so when you call LoadFromFile, the
    problem is you are connecting to the datapipeline that is not connected to
    dsRunTime.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2003

This discussion has been closed.