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.
-
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
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:
-
The ConvertEmptyStringToNull property.
-
The DefaultValue property.
-
The Direction property.
-
The Name property.
-
The Size property.
-
The Type property.
Note