SqlDataSourceCommandType Enumeráció
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Az adatbázisművelet végrehajtásakor használt és SqlDataSource vezérlők által AccessDataSource használt SQL-parancs típusát ismerteti.
public enum class SqlDataSourceCommandType
public enum SqlDataSourceCommandType
type SqlDataSourceCommandType =
Public Enum SqlDataSourceCommandType
- Öröklődés
Mezők
| Name | Érték | Description |
|---|---|---|
| Text | 0 | A megfelelő szöveges tulajdonságban található szöveg egy SQL-lekérdezés vagy -parancs. |
| StoredProcedure | 1 | A megfelelő szövegtulajdonságban található szöveg egy tárolt eljárás neve. |
Példák
Az alábbi példakód bemutatja, hogyan állíthatja be a SelectCommand szöveget egy tárolt eljárás nevére, a SelectCommandType tulajdonságot pedig a StoredProcedure értékre, hogy adatokat kérjen le egy Microsoft SQL Server-adatbázis, és megjelenítse azt egy DropDownList.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList
id="DropDownList1"
runat="server"
DataTextField="LastName"
DataSourceID="SqlDataSource1" />
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommandType="StoredProcedure"
SelectCommand="sp_lastnames">
</asp:SqlDataSource>
<!--
The sp_lastnames stored procedure is
CREATE PROCEDURE sp_lastnames AS
SELECT LastName FROM Employees
GO
-->
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList
id="DropDownList1"
runat="server"
DataTextField="LastName"
DataSourceID="SqlDataSource1" />
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommandType = "StoredProcedure"
SelectCommand="sp_lastnames">
</asp:SqlDataSource>
<!--
The sp_lastnames stored procedure is
CREATE PROCEDURE sp_lastnames AS
SELECT LastName FROM Employees
GO
-->
</form>
</body>
</html>
Megjegyzések
Az SqlDataSourceCommandType enumerálást a SqlDataSource vezérlők használják AccessDataSource a , SelectCommand, InsertCommandés UpdateCommand tulajdonságokban DeleteCommandtalálható SQL-parancs típusának leírására. A Szöveg érték azt jelzi, hogy a szöveg EGY SQL-lekérdezés vagy parancssztring, míg a StoredProcedure érték azt jelzi, hogy a szöveg egy tárolt eljárás neve.