Question
“How do I launch the Query Wizard outside the designer as a stand-alone dialog?”
Solution
The query Wizard can be launched separate from the designer and used to generate SQL as a stand-alone dialog. Start by creating a TdaQueryWizardDialog 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: LaunchQueryWizardViaCode.zip
Delphi code sample:
procedure TForm1.Button1Click(Sender: TObject);
var
lDialog: TdaQueryWizardDialog;
begin
lDialog := TdaQueryWizardDialog.Create(Application);
try
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);
if (lDialog.NextAction = ppnaPreview) then
beep;
end;
finally
lDialog.Free;
end;
end;