Solved

Procedure or function has too many arguments specified.

Posted on 2009-05-15
1
336 Views
Last Modified: 2012-05-07
Hello,

I have an insert on my page that that runs this procedure:
It works if I run the procedure itself... otherwise when I clicked on the button I got this:

 Procedure or function sp_EvaluationVisitInsert 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 sp_EvaluationVisitInsert has too many arguments specified.

Source Error:

Line 139:        myConnection.Open();
Line 140:        
Line 141:        cmd3.ExecuteNonQuery();
Line 142:        lblMessage3.Text = "You have Created a Evaluation Visit Record!";
Line 143:        myConnection.Close();


alter  PROCEDURE sp_EvaluationVisitInsert(
      @ParticipantID as int,
      @EvaluationID as int,
      @DateEvaluation as datetime) AS
      
BEGIN
/*
declare @ParticipantID as int,
      @EvaluationID as int,
      @DateEvaluation as datetime

set  @ParticipantID = '3'
set  @EvaluationID ='1'
set  @DateEvaluation ='05/12/2009'
*/

--if not exists (select ParticipantID from tbl_Participant where ParticipantID = @ParticipantID)


INSERT INTO tbl_EvaluationVisit(ParticipantID,
                    EvaluationID,
                    DateEvaluation
                    )
VALUES
      (@ParticipantID,
       @EvaluationID,
       @DateEvaluation
      )

UPDATE tbl_Participant SET  tbl_Participant.EvaluationVisitID = tbl_EvaluationVisit.EvaluationVisitID  
FROM tbl_Participant join tbl_EvaluationVisit ON tbl_Participant.ParticipantID = tbl_EvaluationVisit.ParticipantID


END


protected void EvaluationVisitAdd_Click(object sender, EventArgs e)

    {
 

        // create the insert command
 

        SqlCommand cmd3 = new SqlCommand("sp_EvaluationVisitInsert", myConnection);

        cmd3.CommandType = CommandType.StoredProcedure;

        cmd3.Parameters.Add(new SqlParameter("@ParticipantID", txtParticipantID.Text.Trim()));

       

        string strDateEvaluation = txtEvaluationDate.Text.Trim();

        cmd3.Parameters.Add(new SqlParameter("@DateEvaluation", strDateEvaluation));
 

        cmd3.Parameters.Add(new SqlParameter("@EvaluationID", ddlEvaluationType.SelectedValue));

        cmd3.Parameters.Add(new SqlParameter("@ParticipantLastName", txtLastName.Text.Trim()));

      

        myConnection.Open();

        

        cmd3.ExecuteNonQuery();

        lblMessage3.Text = "You have Created a Evaluation Visit Record!";

        myConnection.Close();
 

      
 

      //  Response.Redirect("participantEdit.aspx?r=" + ParticipantID);
 

        myConnection.Close();
 
 
 

    }

Open in new window

0
Comment
Question by:Romacali
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24399981
your procedure has 3 parameters, but your c# code adds 4 parameters ...
I think the maths are obvious...
aka:
        cmd3.Parameters.Add(new SqlParameter("@ParticipantLastName", txtLastName.Text.Trim()));
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now