Adding a new Query and launching FastQueryBuilder

Mark ElderMark Elder SD, USA
edited 4:10AM in FastReport 4.0
Hello,

I am trying to give my users a button to add their own query when editing a report. I am adding a ADO Database object if it does not already exist; setting the connection string; then adding a ADO Query and attaching it to the database.

As the last step I would like to open FastQueryBuilder for the SQL of my newly created query. If that is not possible I would like to at least open up the SQL Editor so they only need to click on the FastQueryBuilder button.

Here is the code I have working so far. I am stumped on what I need to do in order to open up the edit window for the new query.

Thanks,

Mark
procedure TReportPlugin.actDesignerReportAddQueryExecute(Sender: TObject);
const
  ConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Persist Security Info=False';
var
  Database: TfrxADODatabase;
  Query: TfrxADOQuery;
begin
  inherited;

  Database := TfrxADODatabase(frxReport.FindComponent('MgrDatabase'));

  if Database = nil then
  begin
    // Add the Database
    Database := TfrxADODatabase.Create(frxReport.Pages[0]);
    Database.Name := 'MgrDatabase';
    Database.DatabaseName := Format(ConnectionString, [FExtraVariables.Values['MgrDatabase']]);
    Database.LoginPrompt := false;
    Database.Top := 50;
    Database.Left := 50;
    Database.Connected := true;
  end;

  // Add a new Query and hook it up to the database
  Query := TfrxADOQuery.Create(frxReport.Pages[0]);
  Query.CreateUniqueName;
  Query.Database := Database;
  Query.Top := 100;
  // This is not perfect but at least gives us a chance that multiple queries
  // will not be stacked right on top of each other hiding some of them.
  Query.Left := frxReport.DataSets.Count * 40;

  // The data set still needs to be added so the Treeview showing the avaliable data
  // sees this dataset.
  frxReport.DataSets.Add(Query);

  FDesignerForm.ReloadPages(0);
  FDesignerForm.Modified := true;

  // Launch the query builder
  //Query.??

end;

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.