English 中文(简体)
如何确定SqlDataSource储存程序参数价值
原标题:How to specify parameter value for stored procedure in SqlDataSource

作为使用SqlDataSource的申报性辛醇的新产品,我试图为储存程序确定参数的价值。 我有一个客户——通过请求目标传递的ID,我需要确定客户—— 在SqlDataSource储存程序之前的身份证已经执行。

我有两个问题。

  1. 储存程序参数是否必须在业余标记中预先界定,或者是否可在编码背后动态添加?

  2. 是否有任何实例显示SqlDataSource在储存程序和参数上的标记,以及在编码背后确定该参数的价值?

最佳回答

有了网4,你可以......

1.It can be added dynamically, but you would have to provide your own code expression builder (for further info see here) 1.1 You can also use different parameter to achieve same goal, like :

“entergraph

2. 结 论

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  ConnectionString="<%$ ConnectionStrings:yourConnectionString %>" 
  SelectCommand="YourStoreProcedure" SelectCommandType="StoredProcedure">
  <SelectParameters>
     <asp:ControlParameter Name="yourParameterName" ControlID="controlThatHoldsParameterValue" PropertyName="Text" />
  </SelectParameters>

问题回答

这是使用SqlDataSource(包括方案设定参数)的参数查询(保存程序和文本)的一个相当彻底的例子。 ASP.NET——使用SqlDataSource的参数。

 <asp:SqlDataSource ID="ADSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ADConnection %>"
    SelectCommand="GetProfile" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="InputTextBox" Name="Host" PropertyName="Text" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

GetProfile is the stored proc name and Host is parameter name, which is retreived from a texbox called InputTextBox





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签