title: Procedure or function 'usp_StoredProcName' expects parameter '@inputVal', which was not supplied
body: <p>I am using a code to call a Stored Procedure having 2 output and 1 input parameter. But i keep getting an error every time I call this stored proc:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[usp_StoredProcName]
  @inputVal nvarchar(255),
  @isError bit OUTPUT,
  @errorInfo nvarchar(255) OUTPUT
  AS BEGIN
  DECLARE @totalRow int = 0;
  DECLARE @inputValID uniqueidentifier;
  
  SET @isError = 1;
  SET @errorInfo = '';
  
  SELECT @inputValID = [inputValID]
  FROM testTable
  WHERE inputVal = @inputVal;
  
  IF @inputValID IS NULL
  BEGIN
  SET @isError = 0;
  SET @errorInfo = 'inputVal not found';
  RETURN
  END
  END
  </code></pre>
  
  <p>I have used couple of C# methods to call the stored proc and I get they all return this error:</p>
  
  <p>Procedure or function 'usp_StoredProcName' expects parameter '@inputVal', which was not supplied.</p>
  
  <p>C# Method 1 (to call the stored proc)</p>
  
  <pre><code>using (SqlConnection con = new SqlConnection(myFullConncectionStringToDB))
  {
  using (SqlCommand cmd = new SqlCommand("usp_StoredProcName", con))
  {
  cmd.CommandType = CommandType.StoredProcedure;
  
    cmd.Parameters.AddWithValue("@inputVal", "MyParamVal_12345");
  
    cmd.Parameters["@isError"].Direction = ParameterDirection.Output;
    cmd.Parameters["@errorInfo"].Direction = ParameterDirection.Output;
  
    con.Open();
    cmd.ExecuteNonQuery();
  
    var isError = cmd.Parameters["@isError"].Value;
    var errInfo = cmd.Parameters["@errorInfo"].Value;
    con.Close();
  }
  }
  </code></pre>
  
  <p>Method 2 ( to call the stored proc)</p>
  
  <pre><code>SqlConnection con = new SqlConnection(myFullConncectionStringToDB);
  SqlCommand cmd = new SqlCommand("usp_StoredProcName", con);
  cmd.CommandType = CommandType.StoredProcedure;
  
  SqlParameter in_parm = new SqlParameter("@inputVal", SqlDbType.NVarChar);
  in_parm.Size = 255;
  in_parm.Value = "MyParamVal_12345";
  in_parm.Direction = ParameterDirection.Input;
  cmd.Parameters.Add(in_parm);
  
  SqlParameter out_parm = new SqlParameter("@errorInfo", SqlDbType.NVarChar);
  out_parm.Size = 255;
  out_parm.Direction = ParameterDirection.Output; 
  cmd.Parameters.Add(out_parm);
  
  SqlParameter out_parm1 = new SqlParameter("@isError", SqlDbType.Bit);
  out_parm1.Direction = ParameterDirection.Output; 
  cmd.Parameters.Add(out_parm1);
  
  con.Open();
  cmd.ExecuteNonQuery();
  con.Close();
  </code></pre>
  
  <p>Both of the above methods I tried return the same error:</p>
  
  <pre><code>Procedure or function 'usp_StoredProcName' expects parameter '@inputVal', which was not supplied.
  </code></pre>
  
  <p>Please tell me what am I doing wrong here in my C# code to execute the stored procedure.</p>
  
  <p>I am clearly passing the parameter value in both of my methods but can't figure out why I keep getting this error. </p>
  
  <p>Thank you for your help.</p>