如何在sql datatsource中的存储过程中传递参数 [英] how to pass parameter in stored procedure in sql datatsource

查看:104
本文介绍了如何在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.


这篇关于如何在sql datatsource中的存储过程中传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆