The following code shows how to create a dataview in code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
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 } |