Question
“How do I launch the Query Designer outside the designer as a stand-alone dialog?”
Solution
The query designer can be launched separate from the designer and used to generate SQL as a stand-alone dialog. Start by creating a TdaQueryDesignerForm object and assigning it a SQL object to use. Once the dialog has been used and closed, access the SQL object to obtain the generated SQL code.
Download: LaunchQueryDesignerViaCode.zipLaunchQueryDesignerViaCodeADO.zip
Delphi code sample:
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 |
procedure TForm1.Button1Click(Sender: TObject); var lDialog: TdaQueryDesignerForm; begin lDialog := TdaQueryDesignerForm.Create(Application); lDialog.SQLClass := TdaSQL; lDialog.SQL.Assign(FSQL); lDialog.Initialize; {show form} if (lDialog.ShowModal = mrOK) then begin FSQL.Assign(lDialog.SQL); Memo1.Lines.AddStrings(lDialog.SQL.SQLText); end; lDialog.Free; end; procedure TForm1.FormCreate(Sender: TObject); begin FSession := TdaBDESession.Create(Self); {set SQL properties} FSQL := TdaSQL.Create(Self); FSQL.Session := FSession; FSQL.AllowSelfJoin := True; FSQL.DatabaseName := 'DBDEMOS'; FSQL.DatabaseType := dtParadox; FSQL.SQLType := sqBDELocal; end; |