Parameter Collection Editor Dialog Box
Enables you to create and configure parameters for SQL queries, business object methods, or filtering expressions associated with the ObjectDataSource, 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
How to: Connect to a SQL Server Database Using the SqlDataSource Control
How to: Connect to an Access Database Using the SqlDataSource Control
How to: Connect to an ODBC Database Using the SqlDataSource Control
How to: Connect to an Oracle Database Using the SqlDataSource Control
How to: Enable Filtering for SqlDataSource Controls (Visual Studio)
How to: Bind to Data in a Templated Control in Visual Studio
How To: Secure Connection Strings when Using Data Source Controls
Editing the Parameter Collection
The Parameter Collection Editor dialog box is displayed when you are using the Properties window to configure an ObjectDataSource, SqlDataSource, or AccessDataSource control in Design view.
Select the SqlDataSource or AccessDataSource control on the design surface, and then select the FilterParameters property in the Properties window to open the Parameter Collection Editor dialog box. For the ObjectDataSource control, select the DeleteParameters, FilterParameters, SelectParameters, and UpdateParameters properties in the Properties window to open the Parameter Collection Editor dialog box.
Parameter Naming
The statements or stored procedures in the Parameter Collection 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 editor is divided into two panes. In the left pane you add and remove parameters, and in the right pane you set properties for individual parameters, among them:
The ConvertEmptyStringToNull property.
The DefaultValue property.
The Direction property.
The Name property.
The Size property.
The Type property.
UI Elements
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.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 a parameter down in the hierarchy
Delete a parameter from the hierarchy
Parameter Source
Specifies the data source for the parameter. Each source results in a different Parameter control in the ParameterCollection. The choices are as shown in the following tableSource
Resulting parameter
None
Control
Cookie
Form
Field
QueryString
Session
Show advanced properties
Shows the advanced properties of the currently selected parameter.Properties
Shows the properties of the Parameter control.Hide advanced properties
Hides the advanced properties of the currently selected parameter.