如何在sql datatsource中的存储过程中传递参数

问题描述:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 

            ConnectionString="<%$ ConnectionStrings:maxConnectionString2 %>" 

            SelectCommand="SELECT * FROM [XIN_EventCal]" DeleteCommandType ="StoredProcedure" DeleteCommand ="[Eventcaldelete] ">
</asp:SqlDataSource>


在设计视图中如何在delete命令中传递参数.预先感谢


how to pass parameters in delete command in design view . Advance thanks

ConnectionStrings:maxConnectionString2%>" =" 选择*来自[XIN_EventCal]" DeleteCommandType =" DeleteCommand [E ventcaldelete]" < /asp:SqlDataSource >
ConnectionStrings:maxConnectionString2 %>" SelectCommand="SELECT * FROM [XIN_EventCal]" DeleteCommandType ="StoredProcedure" DeleteCommand ="[Eventcaldelete] "> </asp:SqlDataSource>


在设计视图中如何在delete命令中传递参数.预先感谢


how to pass parameters in delete command in design view . Advance thanks


这是从MSDN获得的示例:
This is an example got from MSDN:
<asp:sqldatasource id="EmployeeDetailsSqlDataSource" xmlns:asp="#unknown">
  SelectCommand="SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = @EmpID"

  InsertCommand="INSERT INTO Employees(LastName, FirstName) VALUES (@LastName, @FirstName); 
                 SELECT @EmpID = SCOPE_IDENTITY()"
  UpdateCommand="UPDATE Employees SET LastName=@LastName, FirstName=@FirstName 
                   WHERE EmployeeID=@EmployeeID"
  DeleteCommand="DELETE Employees WHERE EmployeeID=@EmployeeID"

  ConnectionString="<%


ConnectionStrings:NorthwindConnection%>" OnInserted ="EmployeeDetailsS​​qlDataSource_OnInserted" RunAt ="server"> -选择参数 < SelectParameters > < asp:parameters 名称 =" 类型 Int32 " 默认值 0" / < /SelectParameters > -插入参数 < 插入参数 > < asp:parameters 名称 =" 方向 输出" 类型 Int32" 默认值 0" / > < /insertparameters > < /asp:sqldatasource >
ConnectionStrings:NorthwindConnection %>" OnInserted="EmployeeDetailsSqlDataSource_OnInserted" RunAt="server"> --Parameter for select <SelectParameters> <asp:parameter name="EmpID" type="Int32" defaultvalue="0" /> </SelectParameters> --Parameter for insert <insertparameters> <asp:parameter name="EmpID" direction="Output" type="Int32" defaultvalue="0" /> </insertparameters> </asp:sqldatasource>



请参考:将参数与SqlDataSource控件一起使用 [



Refer:Using Parameters with the SqlDataSource Control[^] for more details.