title: Stored procedure expects parameter though parameter is provided
body: <p>I am using VS 2015 and SQL Server 2016.</p>
  
  <p>In my C# code, I am assigning the parameters which my stored procedure expects, but am getting an error as my stored procedure is expecting a parameter.</p>
  
  <p>My stored procedure:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[SDDeleteTAR]
      @TARKey int
  AS
  BEGIN
      DELETE technical_assistance_requests  
      WHERE request_id = @TARKey
  END
  </code></pre>
  
  <p>My C# code:</p>
  
  <pre><code>Label id = (Label)e.Item.FindControl("REQUEST_ID");
  var x = id.Text;
  int rid = Convert.ToInt32(x);
  
  string cs = ConfigurationManager.AppSettings.Get("connectionString").ToString();
  
  using (SqlConnection con = new SqlConnection(cs))
  {
      SqlCommand cmd = new SqlCommand("SDDeleteTAR", con);
      cmd.CommandType = CommandType.StoredProcedure; 
      cmd.Parameters.AddWithValue("@RequestID", rid); 
  
      con.Open();
      cmd.ExecuteNonQuery(); 
  }
  </code></pre>
  
  <p>When I run this, I get this error:</p>
  
  <blockquote>
    <p>Procedure or function 'SDDeleteTAR' expects parameter '@TARKey', which was not supplied. </p>
  </blockquote>
  
  <p>I am passing the required parameters and executing my command type as <code>CommandType.StoredProcedure</code>, and am not able to resolve this.</p>
  
  <p>I also checked the same issue in StackOverflow <a href="https://stackoverflow.com/questions/18395369/sql-server-stored-procedure-expects-parameter-even-though-the-parameter-is-provi">here</a> but the submitter is missing the command type declaration.</p>
  
  <p>Any help is appreciated, in pointing out where I am going wrong.</p>