SqlDataSourceCommandType 列舉

定義

當執行資料庫作業時,描述 SqlDataSourceAccessDataSource 控制項所使用的 SQL 命令類型。

public enum class SqlDataSourceCommandType
public enum SqlDataSourceCommandType
type SqlDataSourceCommandType = 
Public Enum SqlDataSourceCommandType
繼承
SqlDataSourceCommandType

欄位

StoredProcedure 1

包含在對應文字屬性的文字是預存程序名稱。

Text 0

包含在對應文字屬性的文字是 SQL 查詢或命令。

範例

下列程式碼範例示範如何將文字設定為預存程式的名稱,並將 屬性設定 SelectCommand 為 StoredProcedure 值,以從Microsoft SQL Server資料庫擷取資料,並將其顯示在 中 DropDownListSelectCommandType

<!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>

備註

SqlDataSourceCommandType AccessDataSource 控制項會使用 SqlDataSource 列舉來描述 、 InsertCommandUpdateCommandDeleteCommand 屬性中包含的 SelectCommand SQL命令類型。 Text 值表示文字是SQL查詢或命令字串,而 StoredProcedure 值表示文字是預存程式的名稱。

適用於

另請參閱