Command and Parameter Editor Dialog Box

The Command and Parameter Editor dialog box allows you to create and configure parameters for SQL queries associated with the SqlDataSource and AccessDataSource data source controls. Parameter objects are evaluated at run time, to bind the values of the variables they represent to methods used by data source controls to interact with data. Parameter objects are contained in a ParameterCollection object.

Tasks

Editing the Command and Parameter Collection

The Command and Parameter Editor dialog box is displayed when you are using the Properties window to configure a SqlDataSource or AccessDataSource control in Design view. Select the SqlDataSource or AccessDataSource control on the design surface, and then select the DeleteQuery, InsertQuery, SelectQuery, or UpdateQuery property in the Properties window to open the Command and Parameter Editor dialog box.

Note

Selecting the FilterParameters property in the Properties window opens the Parameter Collection Editor Dialog Box.

Parameter Naming

The statements or stored procedures in the Command and Parameter Editor dialog box can be defined with parameter placeholders. Because different database products use different varieties of SQL, the syntax of the SQL string depends on the current ADO.NET provider being used, which is identified by the ProviderName property. If the SQL string is a parameterized query or command, the placeholder of the parameter also depends on the ADO.NET provider being used. For example, if the provider is the System.Data.SqlClient namespace, which is the default provider for the SqlDataSource class, the placeholder of the parameter is @parameterName. However, if the provider is set to the System.Data.Odbc or System.Data.OleDb namespace, the placeholder of the parameter is ?. For more information about parameterized SQL queries and commands, see Using Parameters with the SqlDataSource Control.

Adding Parameters

The Parameters collection for a command (for example, Parameters) contains a list of parameter objects that are used at run time to pass values to the statements or stored procedures. Thus, there is a parameter object for each parameter value that needs to be passed to a command.

The upper part of the editor shows the delete, insert, select, or update command. The bottom part of the editor is divided into two panes. In the left pane, you add and remove parameters; in the right pane, you set properties for individual parameters, among them:

UI Elements

  • DELETE command or INSERT command or SELECT command or UPDATE command
    Shows the current command. The type of command shown depends on what property was selected in the Properties window.

  • Refresh Parameters
    Adds any parameters defined in the SQL command to the Parameters section in the dialog box. Clicking the Refresh Parameters button does not remove any parameters that appear in the Parameters section but are not used in the SQL command.

  • Query Builder
    Brings up the Query Builder dialog box. For more information, see Query and View Designer Tools.

  • Parameters
    Shows the parameters currently in the parameter collection.

  • Add Parameter
    Creates a new parameter in the collection. By default, the parameter is named newparameter. Select the Name of the parameter to change it.

  • Show advanced properties
    Shows the advanced properties of the currently selected parameter.

  • Hide advanced properties
    Hides the advanced properties of the currently selected parameter.

  • Parameter Order
    Defines the order in which the parameters are listed. You can rearrange parameters by clicking the appropriate buttons, as shown in the following table.

    To

    Click this button

    Move a parameter up in the hierarchy

    Move Up Button

    Move a parameter down in the hierarchy

    Move Down Button

    Delete a parameter from the hierarchy

    Delete Button
  • Parameter Source
    Specifies the data source for the parameter. Each source results in a different Parameter control in the ParameterCollection. The choices are:

    Source

    Resulting parameter

    None

    Parameter

    Control

    ControlParameter

    Cookie

    CookieParameter

    Form

    FormParameter

    Field

    ProfileParameter

    QueryString

    QueryStringParameter

    Session

    SessionParameter

See Also

Reference

Add WHERE Clause Dialog Box - SqlDataSource

Concepts

Using Parameters with the SqlDataSource Control

Query and View Designer Tools