Home
 Index > ASP.NET Web Applications > Procedure or function has too many arguments sp...

ASP.NET Web Applications:  Databinding , GridView , SqlDataSource , FormView , DetailsView

Procedure or function has too many arguments specified

This error may occur when binding a control (GridView, FormView or DetailView) to a SqlDataSource.

Added on 3 Jun 2008

Scenarios:

Scenario Summary:
SqlDataSource UpdateParemeters specified for procedure used by a GridView.
Scenario Details:

GridView's UpdateCommand throws the error "Procedure or function editArea has too many arguments specified" even though the exact input and ouput parameters are specified in the UpdateParameters section of the SqlDataSource.

Removing output parameters from the UpdateParameters list results in the following error:  Procedure or function 'xxx' expects parameter '@xxx', which was not supplied.

Added on 3 Jun 2008

Solution Summary:
All fields specified in the FormView's select statement that are bound to controls using Bind("FieldName") will be passed as parameters to the Update stored procedure.
Solution Details:

 

  • If you are only displaying data, but do not need to use the data for the update procedure, use Eval("FieldName") Instead of Bind("FieldName") to display the Selected data in FormView Web controls.
  • If you need to use Bind("FieldName') rather than Eval("FieldName") because you will use that field for Inserts (though not for Updates), add the bound field as a parameter for the Update procedure (even though you won't be using it in the procudure).  Since every Bound field in the FormView is passed to the Update procedure, you need to declare it as a parameter in your procedure.
Was this solution useful? Yes No Added on 3 Jun 2008
Rating: 

Solution Summary:
The OldValuesParameterFormatString (Typically, "original_") might be passed as a parameter to the Update procedure.
Solution Details:
Simply remove the OldValuesParameterFormatString property from your SqlDataSource.
Was this solution useful? Yes No Added on 3 Jun 2008
Rating: 

Solution Summary:
Set the command type to "Text", instead of "StoredProcedure" and change the stored procedure name to "EXEC spName @param, ..."
Solution Details:

Follow these steps:

  1. Configure your datasource as you would normally using StoredProcedure the DeleteCommandType.

  2. From the Properties pane, click "..." next to the DeleteQuery (Query) property to open up the Command and Parameter Editor.

  3. Refresh your Parameters list and remove any unwanted ones such as RETURN_VALUE. Configure your params as you would normally.

  4. Modify the text in the DELETE command textbox from [SP_MyDeleteStoredProcedure]  to [EXEC SP_MyDeleteStoredProcedure @Param1, @ParamN]. ***

  5. Close the Command and Parameter Editor window.

  6. Finally, back in the Properties pane, change the DeleteCommandType from [StoredProcedure] to [Text].

 *** Note: The parameters in the Parameters list do not need the @; leave the names as they appear. However in the Command text, use the same name, but add @.

 The SqlDataSource should look similar to this:

<asp:SqlDataSource ID="dsCustomerOrders" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
    SelectCommand="CustomerOrders_GetByCustomerId" SelectCommandType="StoredProcedure" 
    
DeleteCommand="EXEC CustomerOrders_DeleteOrder @CustomerOrderId" DeleteCommandType="Text">

    <SelectParameters>
        <asp:ControlParameter ControlID="gvCustomers" Name="CustomerId" PropertyName="SelectedDataKey.Value" Type="Int32" />
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter DefaultValue="" Name="CustomerOrderId" Type="Int32" />
    </DeleteParameters>
</
asp:SqlDataSource>
Was this solution useful? Yes No Added on 10 Dec 2008
Rating: 

Copyright 2014 © E-Centric, Inc. | Terms of Use