System.Web.UI.WebControls Namespace
Describes the type of SQL command used by the SqlDataSource and AccessDataSource controls when performing a database operation.
Member |
Description |
StoredProcedure |
The text contained in a corresponding text property is the name of a
stored procedure. |
Text |
The text contained in a corresponding text property is a SQL query or
command. |
The SqlDataSourceCommandType enumeration is used by the SqlDataSource and AccessDataSource controls to describe the type of SQL command contained in the SelectCommand, InsertCommand, UpdateCommand, and DeleteCommand properties. The Text value indicates that the text is a SQL query or command string while the StoredProcedure value indicates that the text is the name of a stored procedure.
The following example demonstrates how to set the SelectCommand text to the name of a stored procedure and the SelectCommandType property to the StoredProcedure value to retrieve data from a Microsoft SQL Server database and display it in a DropDownList.
<asp:DropDownList runat = "server"
id = "DropDownList1"
DataTextField = "LastName"
DataSourceID = "SqlDataSource1" />
<asp:SqlDataSource runat = "server"
id = "SqlDataSource1"
ConnectionString = "<%$ ConnectionStrings:MyNorthwind%>"
SelectCommandType = "StoredProcedure"
SelectCommand = "sp_lastnames">
</asp:SqlDataSource>