Question
“How do I search the available dataviews created in DADE for a specific one?”
Solution
Use the TppDataView.Description property to find the name of each dataview and locate the one you need. Start by accessing the datamodule using the daGetDataModule routine. Next loop through each dataview in the TppDataModule.DataViews list to find the desired dataview.
Download: SearchDataviewsByName.zip
Sample Delphi 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 |
procedure TForm1.ppReport1BeforePrint(Sender: TObject); var lDataModule: TdaDataModule; liIndex: Integer; lDataView: TdaQueryDataview; lDataPipeline: TppDBPipeline; lSQL: TdaSQL; lsPipelineName: String; begin {get the datamodule} lDataModule := daGetDataModule(ppReport1); lsPipelineName := ''; if (lDataModule <> nil) then begin for liIndex := 0 to lDataModule.DataViewCount - 1 do begin lDataView := TdaQueryDataView(lDataModule.DataViews[liIndex]); if (lDataView <> nil) and (lDataView is TdaQueryDataView) then begin {only custom dataviews can have multiple data pipelines} lDataPipeline := TppDBPipeline(lDataView.DataPipelines[0]); if (lDataPipeline = ppReport1.DataPipeline) then begin ShowMessage(lDataView.Description); lsPipelineName := lDataView.Description; {do something with SQL object} lSQL := lDataview.SQL; end; end; end; end; end; |