Why does this return null?
//seedDate is set to DateTime.Now; con is initialized and open. Not a problem with that using (SqlCommand command = new SqlCommand("fn_last_business_date", con)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@seed_date", seedDate);//@seed_date is the param name object res = command.ExecuteScalar(); //res is always null }
But when I call it directly in the DB as follows:
select dbo.fn_last_business_date('8/3/2011 3:01:21 PM') returns '2011-08-03 15:01:21.000'
which is the result that I expect to see when I call it from code
Why why why?
source share