Active Query Builder support area

Quick Start Guide for the VCL Edition (Delphi & C++Builder)

Last modified:

Dashboard Quick Start

1st way: Placing the Active Query Builder control on a form.

Follow the steps below to place a component on a form using Delphi IDE.

  1. Place the TacQueryBuilder component on the form.
  2. Place required metadata and syntax provider components on the form (read more about syntax and metadata providers). Define database connection for the metadata provider.

  3. Link the components above to the TacQueryBuilder by setting MetadataProvider and SyntaxProvider properties.

  4. Place the TacSQLBuilderPlainText component on the form to get SQL code generated by the Query Builder with formatting. Link it to the TacQueryBuilder component by setting its QueryBuilder property.
  5. Add the TMemo or any other text editing component (for example, TSynEdit) to a form.

  6. Now you should establish a connection between the TacSQLBuilderPlainText and the TMemo components.
    Enter the following code to OnExit event of TMemo component:

    acQueryBuilder1.SQL := Memo1.Text;


    Enter the following code to OnSQLUpdated event of TacSQLBuilder component:

    Memo1.Text := acSQLBuilderPlainText1.SQL;


  7. Execute the following code to load metadata and activate Active Query Builder:
    // syncronous loading; may take a long time in case of large database schema


    // asyncronous loading; allows to work with the component almost instantly. 
    // database schema tree will be filled after completion of the metadata loading process.


  8. That's all! Now you can run your application.

    Don't forget to activate your database connection component.


2nd way: Creating a component programmatically.

The following sample illustrates the programmatic creation of needed objects to work with the component.

unit uActiveQueryBuilder;

  // ...
  acAST, acQBBase;


  TForm1 = class(TForm)
    // ...
    adoConnection: TADOConnection;
    acQueryBuilder: TacQueryBuilder;

    // specify the needed type of metadata provider according to your database connection
    acMetadataProvider: TacADOMetadataProvider;

    // specify the needed type of syntax provider for your database server
    acSyntaxProvider: TacMSAccessSyntaxProvider; 
    acPlainTextSQLBuilder: TacSQLBuilderPlainText;
    // ...


procedure TForm1.FormCreate(Sender: TObject);
  acQueryBuilder := TacQueryBuilder.Create(Self);
  acMetadataProvider := TacADOMetadataProvider.Create(Self);
  acSyntaxProvder := TacMSAccessSyntaxProvider(Self);

  adoConnection := TADOConnection.Create(Self);
  adoConnection.ConnectionString := 'Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;Persist Security Info=False;';

  acMetadataProvider.Connection := adoConnection;
  acQueryBuilder.MetadataProvider := acMetadataProvider;
  acQueryBuilder.SyntaxProvider := acSyntaxProvider;

  acPlainTextSQLBuilder := TacSQLBuilderPlainText.Create(Self);
  acPlainTextSQLBuilder.QueryBuilder := acQueryBuilder;

  // get the needed metadata to fill the Database Schema Tree:

  // specify the initial SQL if needed:
  acQueryBuilder.SQL := 'SELECT * FROM Table1';

  // display the formatted SQL query to the user:


This article was helpful for 1 person. Is this article helpful for you?