Click here to Skip to main content
11,410,750 members (63,458 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: StoredProcedures
Hello friends,
I have used, a proceedure...
how to get...recover this error...
""Procedure or function str_feedback has too many arguments specified."""

    protected void btn_submit_Click(object sender, EventArgs e)
    {
        try
        {
            cnn.ConnectionString = ConfigurationManager.ConnectionStrings["jin"].ConnectionString;
            SqlCommand cm = new SqlCommand("str_feedback", cnn);
            cm.CommandType = CommandType.StoredProcedure;
            cm.Parameters.Add("@food_quality", rbt_foodqual.SelectedItem.ToString());
            cm.Parameters.Add("@rate_deliv", rbt_ratedeliv.SelectedItem.ToString());
            cm.Parameters.Add("@rate_money", rbt_ratemoney.SelectedItem.ToString());
            cm.Parameters.Add("@rate_service", rbt_rateservice.SelectedItem.ToString());
            cm.Parameters.Add("@recom_friend", rbt_recomfriend.SelectedItem.ToString());
            cm.Parameters.Add("@about_us", ddl_hearaboutus.SelectedItem.ToString());
            cm.Parameters.Add("@others", txt_others.Text);
            cnn.Open();
            cm.ExecuteNonQuery();
            cnn.Close();
            lbl_msg.Text = "Your Feedback is Submitted Successfully";
        }
        catch (Exception ex)
        {
            //lbl_msg.Text = "There is some problem";
            lbl_msg.Text = ex.Message;
        }
Now this the Proceedure:
USE [JIN]
GO
/****** Object:  StoredProcedure [dbo].[str_feedback]    Script Date: 03/02/2013 15:19:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[str_feedback]
@food_quality nvarchar(50),
@rate_service nvarchar(50),
@rate_deliv nvarchar(50),
@recom_friend nvarchar(50),
@rate_money nvarchar(50),
@about_us nvarchar(50)
AS
BEGIN
declare @others nvarchar(100)
declare @time datetime
select @time=CONVERT(TIME,GETDATE())
declare @entrydate datetime
select @entrydate= GETDATE()+@time
insert into feedback(food_quality,rate_service,rate_deliv,recom_friend,rate_money,about_us,others,entrydate)values(@food_quality,@rate_service,@rate_deliv,@recom_friend,@rate_money,@about_us,@others,@entrydate)
END


[edit]Code block added - OriginalGriff[/edit]
Posted 2-Mar-13 0:21am
Edited 2-Mar-13 0:32am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Without seeing the SQL code for the str_feedback procedure, we can't be exact - but check the parameter list. The error indicates that you are supplying seven parameters when the procedure expects six or fewer.
  Permalink  
Comments
Ankit_Sharma1987 at 2-Mar-13 5:29am
   
sir, i have seen in many...is there it is fixed, that if we..will supply more than..six parameters than..it will display this error?
Imtiyaz_mi at 2-Mar-13 5:31am
   
Let us have a look at your stored procedure.
OriginalGriff at 2-Mar-13 5:35am
   
No - if your procedure requires 4 parameters, then you must give it four: not three, not five.
If you procedure wants seven parameters, then giving it seven is fine. But if the procedure only understands six parameters, then it will throw this error when you provide seven.
Ankit_Sharma1987 at 2-Mar-13 5:41am
   
Hmmm, thanxx to clear my doubt....
sir..

OriginalGriff at 2-Mar-13 6:03am
   
You're welcome
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi

Compare the parameters in stored procedure with the parameters passing from C#. Make sure that both should match.

Let's say you have 5 parameters in an stored procedure in that case you are supposed to pass only 5 parameters from C#.


Hope this will help you out!
  Permalink  
Comments
Ankit_Sharma1987 at 2-Mar-13 5:41am
   
thankxx, sir..i cleared it..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

USE [JIN]
GO
/****** Object: StoredProcedure [dbo].[str_feedback] Script Date: 03/02/2013 15:19:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[str_feedback]
@food_quality nvarchar(50),
@rate_service nvarchar(50),
@rate_deliv nvarchar(50),
@recom_friend nvarchar(50),
@rate_money nvarchar(50),
@others nvarchar(100),<------------Changed this-----
@about_us nvarchar(50)
AS
BEGIN
declare @time datetime
select @time=CONVERT(TIME,GETDATE())
declare @entrydate datetime
select @entrydate= GETDATE()+@time
insert into feedback(food_quality,rate_service,rate_deliv,recom_friend,rate_money,
about_us,others,entrydate)values(@food_quality,@rate_service,@rate_deliv,@recom_friend,
@rate_money,@about_us,@others,@entrydate)
END

The parameter @others should be, declared inside the, procedure!!
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,918
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 2 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100