Error on Gridview Update Page -- Procedure or function uspUpdateSellingZone has too many arguments specified.

Last post 08-26-2008 6:14 PM by sbudlong. 3 replies.

Sort Posts:

  • Error on Gridview Update Page -- Procedure or function uspUpdateSellingZone has too many arguments specified.

    08-26-2008, 9:16 AM
    • Member
      65 point Member
    • sbudlong
    • Member since 08-19-2007, 8:32 PM
    • Posts 124

    I get this error when I click Update in the page code below, using a stored procedure. I built a similar Insert page, which works normally. Can anyone see the error on this page? I don't think it's a problem with the stored procedure. 

     

    Procedure or function uspUpdateSellingZone has too many arguments specified.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Procedure or function uspUpdateSellingZone has too many arguments specified.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SqlException (0x80131904): Procedure or function uspUpdateSellingZone has too many arguments specified.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3244
       System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +186
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1121
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +407
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +495
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +921
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +179
       System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1143
       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +835
       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +163
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +119
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +107
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +178
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838
    

     

    ************************************************************* 

    Page code

     

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

    DataKeyNames="SellingZoneKey" DataSourceID="SqlDataSource1">

    <Columns>

     

    <asp:CommandField ShowEditButton="True" />

    <asp:BoundField DataField="SellingZoneKey" HeaderText="SellingZoneKey" InsertVisible="False"

    ReadOnly="True" SortExpression="SellingZoneKey" />

    <asp:BoundField DataField="Zone" HeaderText="Zone" SortExpression="Zone" />

    <asp:BoundField DataField="Subzone" HeaderText="Subzone" SortExpression="Subzone" />

    <asp:BoundField DataField="Descr" HeaderText="Descr" SortExpression="Descr" />

    <asp:BoundField DataField="PDiv" HeaderText="PDiv" SortExpression="PDiv" />

    <asp:BoundField DataField="Level" HeaderText="Level" SortExpression="Level" />

    <asp:CheckBoxField DataField="IsHSQ" HeaderText="IsHSQ" SortExpression="IsHSQ" />

     

    </Columns>

    </asp:GridView>

    <br />

    &nbsp;<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MEDataWarehouseConnectionString %>"

    SelectCommand="uspGetSellingZones" UpdateCommand="uspUpdateSellingZone" SelectCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">

    <UpdateParameters>

    <asp:Parameter Name="sintSellingZoneKey" Type="Int16" />

    <asp:Parameter Name="sintZone" Type="Int16" />

    <asp:Parameter Name="sintSubzone" Type="Int16" />

    <asp:Parameter Name="strDescr" Type="String" />

    <asp:Parameter Name="intPDiv" Type="Int32" />

    <asp:Parameter Name="tintLevel" Type="Byte" />

    <asp:Parameter Name="bitIsHSQ" Type="Boolean" />

    </UpdateParameters>

    </asp:SqlDataSource>

    **********************************************************************

     Stored Procedure

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    go

     

     

     

     

     

     

    ALTER PROCEDURE [dbo].[uspUpdateSellingZone]

    @sintSellingZoneKey smallint,

    @sintZone smallint = -1,

    @sintSubzone smallint = -1,

    @strDescr varchar(100),

    @intPDiv int,

    @tintLevel tinyint,

    @bitIsHSQ bit,

    @SCDBeginDate smalldatetime

     

    AS

    UPDATE [tblSellingZones_Dim]

    SET [Zone] = @sintZone

    , [Subzone] = @sintSubzone

    , [Descr] = @strDescr

    , [PDiv] = @intPDiv

    , [Level] = @tintLevel

    , [IsHSQ] = @bitIsHSQ

    , [SCDBeginDate] = getdate()

    WHERE [SellingZoneKey] = @sintSellingZoneKey

     

     

  • Re: Error on Gridview Update Page -- Procedure or function uspUpdateSellingZone has too many arguments specified.

    08-26-2008, 9:42 AM
    Answer
    • All-Star
      86,764 point All-Star
    • ecbruck
    • Member since 12-30-2005, 7:39 PM
    • Des Moines, IA
    • Posts 9,209
    • Moderator
      TrustedFriends-MVPs

    You Parameter names match that of your stored procedure, but they don't match the fields used within your BoundFields. Therefore, the fields within your BoundFields in addition to your Parameters are being sent to your stored procedure.

    Instead, it is best to modify the names of your Parameters and stored procedure parameters to match that of your fields. It's not ideal especially if you have naming conventions to follow, but it's by far the easiest way. Otherwise, it's up to you to programmatically assign the values in your GridView to the appropriate Parameter.

    Thanks, Ed

    Microsoft MVP - ASP/ASP.NET

  • Re: Error on Gridview Update Page -- Procedure or function uspUpdateSellingZone has too many arguments specified.

    08-26-2008, 5:34 PM
    • Member
      65 point Member
    • sbudlong
    • Member since 08-19-2007, 8:32 PM
    • Posts 124

    Ed,

    Thank you for the suggestion. I was thinking along that line and may even have tried that. How do I programmatically assign the values in your GridView to the appropriate Parameter? As you suggest.

  • Re: Error on Gridview Update Page -- Procedure or function uspUpdateSellingZone has too many arguments specified.

    08-26-2008, 6:14 PM
    • Member
      65 point Member
    • sbudlong
    • Member since 08-19-2007, 8:32 PM
    • Posts 124

    I found the answer in another post here. It has to do with keeping the same sames for the table columns, the sproc parameters, and the Gridview parameters. Once I did that, the update worked! Two days later than promised! But a moral victory nonetheless!

Page 1 of 1 (4 items)