Click here to Skip to main content
15,300,047 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
I have used, a proceedure...
how to get...recover this error...
""Procedure or function str_feedback has too many arguments specified."""

C#
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:
SQL
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
Updated 1-Mar-13 23:32pm
v3

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.
   
Comments
Ankit_Sharma1987 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?
mimtiyaz 2-Mar-13 5:31am
   
Let us have a look at your stored procedure.
OriginalGriff 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 2-Mar-13 5:41am
   
Hmmm, thanxx to clear my doubt....
sir..

OriginalGriff 2-Mar-13 6:03am
   
You're welcome
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!
   
Comments
Ankit_Sharma1987 2-Mar-13 5:41am
   
thankxx, sir..i cleared it..
SQL

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!!
   
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900