Skip to main content

Binding to Data

The Query Builder control requires a valid data connection to obtain database schema information as well as to generate the resulting query in a proper SQL dialect.

Do the following to specify a data connection to a Query Builder:

  1. Add an XPO connection string specifying a valid connection to the required database to the project’s Web.config file as shown below. For information on XPO connection string formats and examples, review the following help topic: Supported Data Providers.

    <connectionStrings>
        <add name="NorthwindXpo" connectionString=
          "data source=blackbox;integrated security=SSPI;
           initial catalog=DB_Northwind;XpoProvider=MSSqlServer;" />
      </connectionStrings>
    
  2. In the Page_Load event handler, pass the name of the added connection string to the Query Builder control’s ASPxQueryBuilder.OpenConnection method.

    protected void Page_Load(object sender, EventArgs e) {
        ASPxQueryBuilder1.OpenConnection("NorthwindXpo");
    }
    
  3. The Query Builder control is now bound to data. You can run your web application and view the result. The database schema will be automatically obtained from the database and reflected by Query Builder’s lists of the available data tables.