title: Procedure or function xxxxx has too many arguments specified
body: <p>My stored procedure is as follows :</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[sp5]
      @mat NVARCHAR(1000) = NULL,
      @party NVARCHAR(1000) = NULL,
      @place NVARCHAR(1000) = NULL,
      @truk NVARCHAR(1000) = NULL,
      @qty NVARCHAR(10) = NULL,
      @ptm NVARCHAR(10) = NULL,
      @mop NVARCHAR(100) = NULL,
      @tos NVARCHAR(100) = NULL,
      @driver NVARCHAR(100) = NULL,
      @date1 DATE = NULL
  AS
  BEGIN
      DECLARE @sql NVARCHAR(4000); 
      DECLARE @params NVARCHAR(4000); 
      DECLARE @rate nvarchar(10); 
  
      SET @sql ='select  @rate = ['+@mat+']   from tblcos'+ ' where [Name] = @party' 
      set @params = '@party nvarchar (1000), @rate NVARCHAR(10) OUTPUT'  
      exec sp_executesql @sql, @params,@party= @party,@rate = @rate OUTPUT
  
      INSERT INTO tblsls([Party], [Place], [truk], [Material], [Qty], rate, 
                         [Payment], [MOP], [TOS], [driver], [Date]) 
          SELECT 
              @party, @place, @truk, @mat, @qty, @rate, 
              @ptm, @mop, @tos, @driver, @date1
  END
  </code></pre>
  
  <p>aspx.cs code file is as follows :</p>
  
  <pre><code>namespace crusoft
  {
      public partial class WebForm3 : System.Web.UI.Page
      {
          protected void Button1_Click(object sender, EventArgs e)
          {
              string cs = ConfigurationManager.ConnectionStrings["VRAConnectionString"].ConnectionString;
  
              SqlConnection con = new SqlConnection(cs);
  
              SqlCommand cmd = new SqlCommand("sp5", con);
              cmd.CommandType = CommandType.StoredProcedure;
  
              cmd.Parameters.AddWithValue("@date1", SqlDbType.Date).Value = Calendar1.SelectedDate.ToShortDateString();
              cmd.Parameters.AddWithValue("@party", SqlDbType.NVarChar).Value = Ddprt.SelectedValue;
              cmd.Parameters.AddWithValue("@place", SqlDbType.NVarChar).Value = tbpls.Text;
              cmd.Parameters.AddWithValue("@truk", SqlDbType.NVarChar).Value = Tbtru.Text;
              cmd.Parameters.AddWithValue("@mat", SqlDbType.NVarChar).Value = Ddmat.SelectedValue;
              cmd.Parameters.AddWithValue("@qty", SqlDbType.SmallInt).Value = Tbqty.Text;
              cmd.Parameters.Add("@rate", SqlDbType.NVarChar, 10);
              cmd.Parameters["@rate"].Direction = ParameterDirection.Output;
  
              cmd.Parameters.AddWithValue("@ptm", SqlDbType.NVarChar).Value = Tbptm.Text;
              cmd.Parameters.AddWithValue("@mop", SqlDbType.NVarChar).Value = Ddmop.SelectedValue;
              cmd.Parameters.AddWithValue("@tos", SqlDbType.NVarChar).Value = Ddtos.SelectedValue;
              cmd.Parameters.AddWithValue("@driver", SqlDbType.NVarChar).Value = Tbdri.Text;
  
              con.Open();
              cmd.ExecuteNonQuery();
              con.Close();
          }
      }
  }
  </code></pre>
  
  <p>When I run the program it fails, when I execute without the <code>@rate</code> parameter, everything works fine, but I want to execute with the <code>@rate</code> parameter.</p>
  
  <p>I am sure the stored procedure is working correctly. </p>