存储过程传参数
<asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:WorkConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommandType="StoredProcedure" SelectCommand="usp_GetProductOfPD"
runat="server">
存储过程是带参数的,直接在界面绑定的
我如何在界面上直接传递参数勒
[解决办法]
給你個例子
CREATE PROCEDURE [dbo].[GetProductsByCategoryID]
@ProductSubcategoryID int
AS
SELECT ProductID, Name, ProductNumber FROM Production.Product
WHERE ProductSubcategoryID=@ProductSubcategoryID ORDER BY ProductID
Categories:
<asp:DropDownList ID="lstCategories" DataSourceID="categoriesSource" runat="server"
DataValueField="ProductSubcategoryID" DataTextField="Name" AutoPostBack="true"></asp:DropDownList>
<asp:SqlDataSource ID="productsSource" runat="server" ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:AdventureWorks %>"
SelectCommand="GetProductsByCategoryID" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="lstCategories" Name="ProductSubcategoryID" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>