如何设置SqlDataSource的更新命令参数 [英] How to set parameters for SqlDataSource UpdateCommand

查看:513
本文介绍了如何设置SqlDataSource的更新命令参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关的GridView:

For a Gridview:

我想在一个SqlDataSource使用存储过程在第一时间更新命令:

I am trying to use a stored procedure for the first time in a SQLDataSource for the UpdateCommand:

<asp:SqlDataSource ID="TECT_DataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>" 
    ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName %>"
    SelectCommand="SELECT MPID, User_Id, Last_Name, First_Name
                   FROM Scripts.vw_Tect_Exam"
    UpdateCommand="P_TECT_UPD_EXAM_ID" UpdateCommandType="StoredProcedure">  
    <UpdateParameters>                    
        <asp:Parameter Name="MPID" Type="Int32"  />  
        <asp:Parameter Name="User_Id" Type="String" />   
    </UpdateParameters> 
</asp:SqlDataSource>

我想知道的UpdateParameters如何得到它们的值设置的,因为我只指定一个名称?结果
该程序 P_TECT_UPD_EXAM_ID 需要两个参数作为输入:in_MPIDin_UserId结果
我也想知道如何为名称不同的价值观输入参数的程序映射?

I am wondering how the UpdateParameters get their values set, since I only specify a name?
The procedure P_TECT_UPD_EXAM_ID expects two parameters as input: "in_MPID" and "in_UserId"
I am also wondering how to map those values to the input parameters for the procedure as the names are different?

推荐答案

您可以将它们像这样:

例子:在这个例子中MPID是SQL参数名称@MPID

Example : In the example MPID is the sql parameter name @MPID

<UpdateParameters>                    
    <asp:ControlParameter Name="MPID" ControlID="MPID_TextBox" PropertyName="Text  />  
    <asp:ControlParameter Name="User_Id" ControlID="User_Id_TextBox" PropertyName="Text  />  
</UpdateParameters> 

更正:刚刚发现你的PROC参数的名称,以便它必须是

<asp:ControlParameter Name="in_MPID" ...............
<asp:ControlParameter Name="in_User_Id" ...............

希望这有助于....

Hope this helps....

这篇关于如何设置SqlDataSource的更新命令参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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