locked
Procedure or function EditOrd has too many arguments specified. RRS feed

  • Question

  • User1835225731 posted

    Hi all,

    i have a detailsview which i want to insert radiobuttonlist in the detailsview. The problem is when I want to edit and update the data, it appear 

    Server Error in '/' Application.


    Procedure or function EditOrd 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 EditOrd 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 EditOrd has too many arguments specified.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2074350 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5066444 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +215 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +987 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +178 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +394 System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +697 System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +95 System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +1105 System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +444 System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +112 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    This is my .aspx

    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
    AutoGenerateRows="False" DataKeyNames="Purchaser_ID" OnDataBound="DetailsView1_DataBound"
    OnItemUpdating="DetailsView1_ItemUpdating" DataSourceID="SqlDataSource1">
    <FieldHeaderStyle BackColor="#CCFF66" />
    <Fields>
    <asp:BoundField DataField="Purchaser_ID" HeaderText="Purchaser_ID"
    ReadOnly="True" SortExpression="Purchaser_ID" />
    <asp:BoundField DataField="Membership_ID" HeaderText="Membership_ID"
    InsertVisible="False" ReadOnly="True" SortExpression="Membership_ID" />
    <asp:BoundField DataField="Membership_Type" HeaderText="Membership_Type"
    SortExpression="Membership_Type" />
    <asp:BoundField DataField="Membership_Ack" HeaderText="Membership_Ack"
    SortExpression="Membership_Ack" />
    <asp:BoundField DataField="Salutation" HeaderText="Salutation"
    SortExpression="Salutation" />
    <asp:BoundField DataField="FirstName" HeaderText="FirstName"
    SortExpression="FirstName" />
    <asp:BoundField DataField="LastName" HeaderText="LastName"
    SortExpression="LastName" />
    <asp:BoundField DataField="Address_1" HeaderText="Address_1"
    SortExpression="Address_1" />
    <asp:BoundField DataField="Address_2" HeaderText="Address_2"
    SortExpression="Address_2" />
    <asp:BoundField DataField="Address_3" HeaderText="Address_3"
    SortExpression="Address_3" />
    <asp:BoundField DataField="PostCode" HeaderText="PostCode"
    SortExpression="PostCode" />
    <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
    <asp:BoundField DataField="Country" HeaderText="Country"
    SortExpression="Country" />
    <asp:BoundField DataField="MobileNo" HeaderText="MobileNo"
    SortExpression="MobileNo" />
    <asp:BoundField DataField="AlternativeNo" HeaderText="AlternativeNo"
    SortExpression="AlternativeNo" />
    <asp:BoundField DataField="Nationality" HeaderText="Nationality"
    SortExpression="Nationality" />
    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
    <asp:BoundField DataField="Activation" HeaderText="Activation"
    SortExpression="Activation" />
    <asp:BoundField DataField="Remarks" HeaderText="Remarks"
    SortExpression="Remarks" />
    <asp:TemplateField HeaderText="Status" SortExpression="Status">
    <EditItemTemplate>
    <asp:RadioButtonList ID="rblStatus" runat="server">
    <asp:ListItem>Update</asp:ListItem>
    <asp:ListItem>Need Update</asp:ListItem>
    </asp:RadioButtonList>
    </EditItemTemplate>
    <InsertItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Status") %>'></asp:TextBox>
    </InsertItemTemplate>
    <ItemTemplate>
    <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:CommandField ShowEditButton="True" />
    </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:testCRMConnectionString %>"
    SelectCommand="SELECT [Purchaser_ID], [Membership_ID], [Membership_Type], [Membership_Ack], [Salutation], [FirstName], [LastName], [Address_1], [Address_2], [Address_3], [PostCode], [State], [Country], [MobileNo], [AlternativeNo], [Nationality], [Email], [Activation], [Remarks], [Status] FROM [PurchaserDetails] WHERE ([Purchaser_ID]=@Purchaser_ID)"
    UpdateCommand="EditOrd" UpdateCommandType="StoredProcedure">
    <SelectParameters>
    <asp:ControlParameter ControlID="TextBox1" Name="Purchaser_ID"
    PropertyName="Text" />
    </SelectParameters>
    <UpdateParameters>
    <asp:Parameter Name="Purchaser_ID" Type="String" />
    <asp:Parameter Name="Status" Type="String" />
    </UpdateParameters>
    </asp:SqlDataSource>

     and this is my aspx.vb

    Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles DetailsView1.DataBound
            If DirectCast(sender, DetailsView).CurrentMode = DetailsViewMode.Edit Then
                Dim row As DataRowView = DirectCast(DirectCast(sender, DetailsView).DataItem, DataRowView)
                Dim rblStatus As RadioButtonList = DirectCast(DirectCast(sender, DetailsView).FindControl("rblStatus"), RadioButtonList)
                rblStatus.SelectedValue = row(19).ToString()
    
            End If
        End Sub
    
        Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
            Dim rblStatus As RadioButtonList = DirectCast(DirectCast(sender, DetailsView).FindControl("rblStatus"), RadioButtonList)
            SqlDataSource1.UpdateParameters("Status").DefaultValue = rblStatus.SelectedValue
        End Sub

    and this is my StoredProcedure

    ALTER PROCEDURE EditOrd
    
    	@Purchaser_ID nvarchar(50),
    	@Status nchar(20)
    
    AS
    	UPDATE PurchaserDetails
    	SET
    
    	Status = @Status
    
    	WHERE Purchaser_ID=@Purchaser_ID
    
    	RETURN
    

    I dont know how to solve this. Hopefully anyone could help me to solve this.. TQVM


    Monday, September 23, 2013 12:17 AM

Answers

  • User1083584480 posted

    you have forget to pass one parameter. see below you have pass only status but forget to pass purchaseid

     Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating 
    Dim rblStatus As RadioButtonList = DirectCast(DirectCast(sender, DetailsView).FindControl("rblStatus"), RadioButtonList)
    SqlDataSource1
    .UpdateParameters("Status").DefaultValue = rblStatus.SelectedValue
    End Sub
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 23, 2013 12:46 AM