程序必须指定许多参数

Procedure has to many arguments specified

我知道所有的数据类型必须相同并且变量必须具有相同的名称,但据我所知它们都是相同的。我使用相同的参数和变量进行更新并且每次都有效,所以我不确定为什么它们不适合插入。以下是我的存储过程的参数。

@Customer varchar(20),
@Cust_NAMC_ID varchar(10),
@Program varchar(10),
@PO_Type_ID varchar(10),
@Part_No varchar(20),
@Part_Name varchar(50),
@Date_Rcvd varchar(50),
@New_Price decimal (18,4),
@Tooling_Price decimal (18,4),
@RFQ_Num varchar(20),
@Eff_From varchar(50),
@Eff_To varchar(50),
@FG_Part_No varchar(20),
@FG_Part_Name varchar(50),
@Ship_From varchar(50),
@Ship_To varchar(50),
@TG_NAMC varchar(50),
@Vendor_CD int,
@PO_NUM varchar(50),
@REV_NO varchar(20),
@Buyer_Name varchar(200),
@Manager_Name varchar(200),
@BU char(2),
@SAM varchar(50),
@RFQ_To_CUST varchar(50),
@Quoted_Date varchar(50),
@PO_From_FG varchar(50),
@PO_RCVD_Date varchar(50),
@PO_Eff_Date varchar(50)

这些是我的专栏:

                    <telerik:GridTemplateColumn HeaderText="Customer" ItemStyle-CssClass="customerddl" DataField="Customer"
                    FilterControlAltText="Filter Customer" SortExpression="Customer" FilterCheckListEnableLoadOnDemand="true" AutoPostBackOnFilter="true" GroupByExpression="Customer Group By Customer" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="125px" />
                    <ItemTemplate>
                        <telerik:RadLabel runat="server" ID="lblCustomer" Text='<%# DataBinder.Eval(Container.DataItem, "Customer") %>'></telerik:RadLabel>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="Update_Customer" DataSourceID="CustomerDataSource" DataTextField="Name" DataValueField="Name" DefaultMessage="-Select-" CssClass="req-field"></telerik:RadDropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="Insert_Customer" DataSourceID="CustomerDataSource" DataTextField="Name" DataValueField="Name" DefaultMessage="-Select-" CssClass="req-field"></telerik:RadDropDownList>
                    </InsertItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="Cust_NAMC_ID" CurrentFilterFunction="Contains" HeaderText="Customer NAMC">
                    <HeaderStyle Width="115px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Program" CurrentFilterFunction="Contains" HeaderText="Program">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PO_Type_ID" HeaderText="CCP" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Part_No" HeaderText="Component PN" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="110px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Part_Name" HeaderText="Component Name" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="175px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Date_Rcvd" HeaderText="Date Rec'd" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="New_Price" HeaderText="New Price" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Tooling_Price" HeaderText="Tooling" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="RFQ_Num" HeaderText="Toyota Letter Reference RFQ #" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="150px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Eff_From" HeaderText="Effective From" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Eff_To" HeaderText="Effective To" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FG_Part_No" HeaderText="Finished Good PN" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="150px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FG_Part_Name" HeaderText="Finished Good Name" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="200px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Ship_From" HeaderText="Ship From" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="175px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Ship_To" HeaderText="Ship To" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="175px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TG_NAMC" HeaderText="TG NAMC" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Vendor_CD" HeaderText="TG Vendor Code" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PO_NUM" HeaderText="PO NO" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="REV_NO" HeaderText="Rev" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Buyer_Name" HeaderText="Buyer" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="135px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Manager_Name" HeaderText="Manager" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="125px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="BU" HeaderText="Business Unit" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SAM" HeaderText="SAM" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="125px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="RFQ_To_CUST" HeaderText="RFQ to Customer" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Quoted_Date" HeaderText="Quoted Date" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PO_From_FG" HeaderText="PO from FG" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PO_RCVD_Date" HeaderText="PO Received Date" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PO_Eff_Date" HeaderText="Effective Date" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                </telerik:GridBoundColumn>

这些是我的插入参数:

        <asp:Parameter Name="Customer" DbType="String" Direction="Input" />
        <asp:Parameter Name="Cust_NAMC_ID" DbType="String" Direction="Input" />
        <asp:Parameter Name="Program" DbType="String" Direction="Input" />
        <asp:Parameter Name="PO_Type_ID" DbType="String" Direction="Input" />
        <asp:Parameter Name="Part_No" DbType="String" Direction="Input" />
        <asp:Parameter Name="Part_Name" DbType="String" Direction="Input" />
        <asp:Parameter Name="Date_Rcvd" DbType="String" Direction="Input" />
        <asp:Parameter Name="New_Price" DbType="Decimal" Direction="Input" />
        <asp:Parameter Name="Tooling_Price" DbType="Decimal" Direction="Input" />
        <asp:Parameter Name="RFQ_Num" DbType="String" Direction="Input" />
        <asp:Parameter Name="Eff_From" DbType="String" Direction="Input" />
        <asp:Parameter Name="Eff_To" DbType="String" Direction="Input" />
        <asp:Parameter Name="FG_Part_No" DbType="String" Direction="Input" />
        <asp:Parameter Name="FG_Part_Name" DbType="String" Direction="Input" />
        <asp:Parameter Name="Ship_From" DbType="String" Direction="Input" />
        <asp:Parameter Name="Ship_To" DbType="String" Direction="Input" />
        <asp:Parameter Name="TG_NAMC" DbType="String" Direction="Input" />
        <asp:Parameter Name="Vendor_CD" DbType="Int32" Direction="Input" />
        <asp:Parameter Name="PO_NUM" DbType="String" Direction="Input" />
        <asp:Parameter Name="REV_NO" DbType="String" Direction="Input" />
        <asp:Parameter Name="Buyer_Name" DbType="String" Direction="Input" />
        <asp:Parameter Name="Manager_Name" DbType="String" Direction="Input" />
        <asp:Parameter Name="BU" DbType="String" Direction="Input" />
        <asp:Parameter Name="SAM" DbType="String" Direction="Input" />
        <asp:Parameter Name="RFQ_To_CUST" DbType="String" Direction="Input" />
        <asp:Parameter Name="Quoted_Date" DbType="String" Direction="Input" />
        <asp:Parameter Name="PO_From_FG" DbType="String" Direction="Input" />
        <asp:Parameter Name="PO_RCVD_Date" DbType="String" Direction="Input" />
        <asp:Parameter Name="PO_Eff_Date" DbType="String" Direction="Input" />

如有任何帮助,我们将不胜感激。

在您的插入存储过程中,运行 一条打印语句打印出所有参数值 and/or 运行 一条 select 语句执行相同的操作。

例如。

alter insert_sproc
( 
   @Customer varchar(20),
   @Cust_NAMC_ID varchar(10),
   etc….
 )

  begin
   print 'customer parm:' + @Customer 
   print 'Cust_NAMC_ID parm:' + @Cust_NAMC_ID 
   etc..

一旦您确定 parm 值正在正常传递,请将您的注意力转移到实际的插入语句上。

  insert into tableName(customer)
  select @customer

   GO 

看看 运行 插入后会发生什么。记下任何错误消息,例如插入尝试中可能出现的约束或数据类型问题。

答案原来是为插入传递了编辑所需的额外参数。我通过这样做删除了值:

protected void grdCCPSource_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
    e.Command.Parameters.Remove(e.Command.Parameters["@Created_Date"]);
}