Procedure or function has too many arguments specified

Last post 08-06-2008 7:31 PM by sush_jd. 26 replies.

Sort Posts:

  • Procedure or function has too many arguments specified

    10-06-2006, 5:36 AM
    • Loading...
    • zeeshannasir
    • Joined on 09-11-2006, 11:30 AM
    • Pakistan
    • Posts 140

    hello

    i am using a detailsview to update. i am using a stored procedure. but every time i try to update it gives exception "Procedure or function has too many arguments specified". i have tried using formview and gridview also but the exception is same. below is my code. primary key in the table is Company_ID. DataKeyNames is also set to primary key.

    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Company_ID"

    DataSourceID="SqlDataSource1" DefaultMode="Edit" Height="50px" Width="125px">

    <Fields>

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

    ReadOnly="True" SortExpression="Company_ID" />

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

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

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

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

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

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

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

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

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

    <asp:CommandField ShowEditButton="True" />

    </Fields>

    </asp:DetailsView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JSGConnectionString %>"

    SelectCommand="selectCompanyLessLogo" SelectCommandType="StoredProcedure" UpdateCommand="updateCompanyLessLogo"

    UpdateCommandType="StoredProcedure">

    <UpdateParameters>

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

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

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

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

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

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

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

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

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

    <asp:Parameter Name="Company_ID" Type="Int64" />

    </UpdateParameters>

    <SelectParameters>

    <asp:SessionParameter Name="Company_ID" SessionField="Company_ID" Type="Int64" />

    </SelectParameters>

    </asp:SqlDataSource>

     my stored procedure is

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    go

     

    ALTER PROCEDURE [dbo].[updateCompanyLessLogo]

    (

    @cmpName nvarchar(100),

    @address nvarchar(200),

    @country int,

    @desc nvarchar(4000),

    @url nvarchar(50),

    @phone nvarchar(20),

    @contactperson nvarchar(100),

    @contactphone nvarchar(20),

    @city nvarchar(50),

    @Company_ID bigint

    )

    AS

    SET NOCOUNT OFF;

    UPDATE Company

    SET Cmp_Name = @cmpName, Cmp_Address = @address, Country_ID = @country, Description = @desc, Web_Address = @url, Ph_No = @phone,

    Contact_Person = @contactperson, CP_Phone = @contactphone, City = @city

    WHERE (Company_ID = @Company_ID)

    below is my stack trace, may be it can help

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

    [SqlException (0x80131904): Procedure or function updateCompanyLessLogo has too many arguments specified.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857194
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734806
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
       System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +401
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +721
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
       System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +1152
       System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +461
       System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +109
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

     thanks in advance

    Regards

     

    Please Remember to click "Mark as Answer" on this post if it helped you.

    Ch. Zeeshan Nasir
  • Re: Procedure or function has too many arguments specified

    10-06-2006, 8:21 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 5:32 AM
    • Toronto,Canada
    • Posts 836

    you have not passsed any parameters into the stored procedure.Just becoz fields are databound that does not mean that they become parameters. Either assign proper controlparameters or use the original_{0} type of parameters.

  • Re: Procedure or function has too many arguments specified

    10-06-2006, 10:04 AM
    • Loading...
    • zeeshannasir
    • Joined on 09-11-2006, 11:30 AM
    • Pakistan
    • Posts 140

    i am passing parameters to update command. please correct me if i am  wrong. i am passing parameters in following lines of code. and for select i am passing parameters in <selectparameters>. my select is working but my update is not working and i get exception which i have mentioned above in my first post.

     

    <UpdateParameters>

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

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

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

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

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

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

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

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

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

    <asp:Parameter Name="Company_ID" Type="Int64" />

    </UpdateParameters>

    Please Remember to click "Mark as Answer" on this post if it helped you.

    Ch. Zeeshan Nasir
  • Re: Procedure or function has too many arguments specified

    10-06-2006, 11:35 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 5:32 AM
    • Toronto,Canada
    • Posts 836

    this code just says that there are update parameters ......but where do the values of these parameters come from?

    just for testing purposes ......set defaults & then run the code.what could happen is that the default values would be updated on the database then let me know.

  • Re: Procedure or function has too many arguments specified

    10-07-2006, 4:15 AM
    • Loading...
    • zeeshannasir
    • Joined on 09-11-2006, 11:30 AM
    • Pakistan
    • Posts 140
    what do you mean, set defaults? i am new to asp.net so please be descriptive. how to set defaults?
    Please Remember to click "Mark as Answer" on this post if it helped you.

    Ch. Zeeshan Nasir
  • Re: Procedure or function has too many arguments specified

    10-07-2006, 5:11 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 5:32 AM
    • Toronto,Canada
    • Posts 836

    <asp:Parameter Name="name" Type="string" DefaultValue="any_name" />

    Like this u assign DefaultValue  for all parameters & check if the update is really happening.also what database are you using?

  • Re: Procedure or function has too many arguments specified

    10-07-2006, 6:38 AM
    • Loading...
    • zeeshannasir
    • Joined on 09-11-2006, 11:30 AM
    • Pakistan
    • Posts 140

    i have tried what you told me, but there is no change. i still get the same exception.

    i am using sql server 2005.

    Please Remember to click "Mark as Answer" on this post if it helped you.

    Ch. Zeeshan Nasir
  • Re: Procedure or function has too many arguments specified

    10-07-2006, 7:53 AM
    • Loading...
    • SilverSwan
    • Joined on 09-28-2006, 7:35 PM
    • The Netherlands
    • Posts 33
    Use SQL Profiler to see what your code passes to your SQL Stored Procedure.
  • Re: Procedure or function has too many arguments specified

    10-07-2006, 10:11 AM
    • Loading...
    • zeeshannasir
    • Joined on 09-11-2006, 11:30 AM
    • Pakistan
    • Posts 140

    silverswan, i used sql profiler and got whats causing the error, but dont know whats the reason and how to resolve it. my code is passing all the parameters i am telling it in <updateparameters> and in addition its also passing the parameters by names of boundfiled's Datafiled. i.e. its also sending all parameters from boundfileds. for example  @Cmp_Name, @Cmp_Address

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

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

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

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

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

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

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

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

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

    .

    please could any one tell me why is this happening? why its passing parameters twice. once mine and once from <selectparameters>

    Please Remember to click "Mark as Answer" on this post if it helped you.

    Ch. Zeeshan Nasir
  • Re: Procedure or function has too many arguments specified

    10-07-2006, 5:18 PM
    Answer
    • Loading...
    • SilverSwan
    • Joined on 09-28-2006, 7:35 PM
    • The Netherlands
    • Posts 33
    Check the spelling in the parameters it sends twice. Could you show here what SQL Profiler says it passed?
  • Re: Procedure or function has too many arguments specified

    10-09-2006, 2:13 AM