Gets or sets the SQL string that the System.Web.UI.WebControls.SqlDataSource control uses to retrieve data from the underlying database.
Documentation for this section has not yet been entered.
The SqlDataSource.SelectCommand property represents an SQL query or the name of a stored procedure, and is used by the SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) method to retrieve data from a SQL Server database. If you use an asterisk (*) in the Select command to select all columns, and if you use automatic code generation to perform update or delete operations, make sure that no columns have spaces in their names.
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 SqlDataSource.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, which is the default provider for the System.Web.UI.WebControls.SqlDataSource class, the placeholder of the parameter is '@parameterName'. However, if the provider is set to the System.Data.Odbc or System.Data.OleDb, the placeholder of the parameter is '?'. For more information about parameterized SQL queries and commands, see Using Parameters with the SqlDataSource Control.
The SqlDataSource.SelectCommand property can be an SQL string or the name of a stored procedure, if the data source supports stored procedures.
The SqlDataSource.SelectCommand property delegates to the SqlDataSourceView.SelectCommand property of the System.Web.UI.WebControls.SqlDataSourceView object that is associated with the System.Web.UI.WebControls.SqlDataSource control.
For security purposes, the SqlDataSource.SelectCommand property is not stored is view state. Because it is possible to decode the contents of view state on the client, storing sensitive information about the database structure in view state could result in an information disclosure vulnerability.
Values are inserted into parameters without validation, which is a potential security threat. Use the SqlDataSource.Filtering event to validate parameter values before executing the query. For more information, see Script Exploits Overview.