Custom Dataviews

The following code shows how to create a dataview in code:

uses
daDatMod, daQClass, daDataVw, daQuery, daDBBDE; 

{------------------------------------------------------------------------------}
{TForm1.CreateDataView}

procedure TDynamicReport.CreateDataView;
var
lSQL: TdaSQL;
lTable: TdaTable;
lField: TdaField;
  
begin

  {create a datamodule - note: this is only necessary if you need to stream the report definition to an .rtm or database}
  FDataModule := TdaDataModule.CreateForReport(FReport);

  {create a query dataview}
  FDataView   := TdaBDEQueryDataView.Create(Self);
  FDataView.Parent := FDataModule;

  {initialize the dataview}
  FDataView.Init;

  {define database connect and type}
  FDataView.SQL.DatabaseName := 'DBDemos';
  FDataView.SQL.DatabaseType := dtParadox;
  FDataView.SQL.SQLType      := sqBDELocal;
  FDataView.SQL.Session := FDataView.Session;

  {create local version of the SQL object}
  lSQL := TdaSQL.Create(Self);
  lSQL.Assign(FDataView.SQL);

  {modify the local version}
 { lSQL.SQLText.Text := 'Select * from clients';
  lSQL.EditSQLAsText := True;
 }

  lTable := lSQL.AddTable('clients');
  lSQL.AddSelectField(lTable, 'Last_Name');
  lSQL.AddSelectField(lTable, 'First_Name');


  {assign local SQL object values to the dataview}
  FDataView.SQL := lSQL;

  {get a reference to the dataivew's pipeline and assign a Name to the pipeline}
  FPipeline   := TppDBPipeline(FDataView.DataPipelines[0]);
  FPipeline.Name := 'plClient';

  {connect report to datapipeline}
  FReport.DataPipeline := FPipeline;

  lSQL.Free;

end; {procedure, CreateDataView }