A newer version of this page is available. Switch to the current version.

QueryParameter Class

A parameter passed to a SqlQuery.

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v18.2.dll


public sealed class QueryParameter :
Public NotInheritable Class QueryParameter
    Inherits DataSourceParameterBase


A collection of QueryParameter objects is returned by the SqlQuery.Parameters property. This property is also available for the StoredProcQuery class.

The following code illustrates how to bind to a Microsoft SQL Server database and filter the result set of a query by a specified parameter value.

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
// ...

private SqlDataSource BindToData(int parameterValue) {
    // Specify parameters required to connect to a specific data provider.
    MsSqlConnectionParameters connectionParameters =
        new MsSqlConnectionParameters("ServerName", "DataBaseName", null, null, MsSqlAuthorizationType.Windows);

    // Create a data source instance with the specified connection parameters.
    SqlDataSource ds = new SqlDataSource(connectionParameters);

    // Create a query to access fields of the Products data table.
    // End the chain by calling the Build method with a specified query name.
    SelectQuery query = SelectQueryFluentBuilder
        .SelectColumns("CategoryID", "ProductName")

    // Create a query parameter of a required type and assign a value to it.
    QueryParameter parameter = new QueryParameter() {
        Name = "catID",
        Type = typeof(System.Int32),
        Value = parameterValue

    // Filter the query result set using the created parameter.
    query.FilterString = "CategoryID = ?catID";

    // Add the query and fill the data source.

    return ds;

To learn how to link query parameters with report or dashboard parameters using an Expression, refer to the following tutorials.



See Also