Allow users to execute ad-hoc SQL SELECT statements against any table in a database. Queries can be saved for future use and query results can be exported to Excel.


The purpose of this component is to allow a user to perform arbitrary queries against any table in a database and export the resulting data to Excel.

The component supports the following:

  • Select the connection string
  • Select the table
  • Select the fields from the table
  • Define sort orders
  • Execute the query

Once the user execute the query focus is automatically given to the Results pane (shown below) which shows the query results.

The Results pane displaying the records for the user's query.

The user can choose to do the following:

  • Show the SQL for the query
  • Export the query results to Excel
  • Save the query definition for future use

In order to save and load queries you must configure a Repository table. This is done by going to the Project Properties dialog when the Web Control Panel has focus and setting properties for Repository Settings. (See Defining a Repository Table below.)

The list of connection strings that the user can select from is controlled by the choices you define for the ConnectionString dropdown box control on the UX. (See Populating the Connection String Dropdown below.)

For more information about how this template works, watch the Videos below.

Defining a Repository Table

In order to save or load saved queries, you must configure the Repository table. The Repository table is defined in the Web Project Properties:

  1. Go to the Web Projects Control Panel.

  2. Click the Project Properties button in the toolbar to open the Web Project Properties.

  3. In the Repository Settings section, define the Table type and connection properties for the database where the repository table will be created and stored:

    See Repository Settings for more information.
  4. Click OK to save your settings when you are done.

Populating the Connection String Dropdown

When the UX Component based on this template is created, the connection string dropdown box will be blank. In order to use this component, one or more connection strings need to be added to the list of options in the connectionString Dropdownbox control. To do this, follow the steps below:

  1. Select the connectionString control located inside the CONTAINER_QUERY container.

  2. Click the smart field button for the Choices property

  3. Enter the connection strings to display in the Dropdown control - one per line. The connection strings listed must be defined in the web project.


    If you do not have access a data source to use with this template, you can use the Northwind database, which ships with Alpha Anywhere. See Creating AlphaDAO Connection Strings to learn how to create a connection string to this database.

  4. Click OK to save your list when you are done.


Ad-hoc SQL Query Builder

This video shows a sample UX component that allows users to perform ad hoc SQL Select queries against any table in a database. The results can be viewed in a tabular format or exported to Excel.