title: SQL server stored proc "Procedure or function expects parameter, which was not supplied."
body: <p>I've recently changed a couple of functions recently while debugging a cte query (have gotten help here). I just changed a couple of functions.. this got my query to work.. but now when my C# client code calls those functions through stored procs for my program logic, I get the error "Procedure or function 'DateTimeOfNextAvailableDataRun' expects parameter '@NextDateTime', which was not supplied.
  " Maybe multiple values are coming back?</p>
  
  <p>Here's the function in its current form:</p>
  
  <pre><code>ALTER FUNCTION dbo.NextAvailableDataDownloadDateTime()
      RETURNS date
  BEGIN
      RETURN (SELECT DATEADD(hour, 18, MIN(TradingDate)) AS TrDate
      FROM tblTradingDays
      WHERE (DATEADD(hour, 18, TradingDate) &gt; dbo.LatestDataDownloadDate()))
  END
  </code></pre>
  
  <p>And the stored proc that invokes it:</p>
  
  <pre><code>ALTER PROC DateTimeOfNextAvailableDataRun
      @NextDateTime DateTime2 OUTPUT
  AS
      SELECT @NextDateTime = dbo.NextAvailableDataDownloadDateTime()
  </code></pre>
  
  <p>And lastly my client code, which did run before the change:</p>
  
  <pre><code>public DateTime DateTimeOfNxtAvailableDataRun()
              {
                  DateTime dateTimeOfNxtAvailableDataRun;
  
                  using (SqlCommand cmd = new SqlCommand("DateTimeOfNextAvailableDataRun", this.sqlConnection))
                  {
                      cmd.CommandType = System.Data.CommandType.StoredProcedure;
                      cmd.ExecuteNonQuery();
                      dateTimeOfNxtAvailableDataRun = (DateTime)cmd.ExecuteScalar();
                  }
  
                  return dateTimeOfNxtAvailableDataRun;
              }
  </code></pre>
  
  <p>Any takers? Again, the functions work within my sql server query (see recent posts by me) but now the calling code disagrees..</p>