Question
“How do I create a DataPipeline in code?”
Solution
Datapipelines can easily be created dynamically in code by assigning a few key properties.
- Create the TppDBPipeline object:
FDataPipeline := TppDBPipeline.Create(Self);
- Give the pipeline a recognizable name.
FDataPipeline.Name := ‘plCustomers’;
FDataPipeline.UserName := ‘Customers’;
- Assign the DataSource property.
FDataPipeline.DataSource := dsCustomers;
- Assign any other properties you may need.
FDataPipeline.SkipWhenNoRecords := True;
Download: CreateDataPipeline.zip
Sample Delphi code:
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateDataPipeline;
pPReport1.DataPipeline := FDataPipeline;
ppReport1.Print;
end;
procedure TForm1.CreateDataPipeline;
begin
FDataPipeline := TppDBPipeline.Create(Self);
FDataPipeline.RangeBegin := rbFirstRecord;
FDataPipeline.RangeEnd := reLastRecord;
FDataPipeline.RangeEndCount := 0;
FDataPipeline.SkipWhenNoRecords := True;
FDataPipeline.DataSource := DataSource1;
FDataPipeline.Name := 'plCustomers';
FDataPipeline.UserName := 'Customers';
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FDataPipeline.Free;
end;