How To…Create a DataPipeline in Code

Question

“How do I create a DataPipeline in code?”

Solution

Datapipelines can easily be created dynamically in code by assigning a few key properties.

    1. Create the TppDBPipeline object:

FDataPipeline := TppDBPipeline.Create(Self);

    1. Give the pipeline a recognizable name.

FDataPipeline.Name := ‘plCustomers’;
FDataPipeline.UserName := ‘Customers’;

    1. Assign the DataSource property.

FDataPipeline.DataSource := dsCustomers;

    1. 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;