【发布时间】:2011-10-19 10:03:43
【问题描述】:
为什么返回 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
}
但是当我直接在数据库中这样调用它时:
select dbo.fn_last_business_date('8/3/2011 3:01:21 PM')
returns '2011-08-03 15:01:21.000'
这是我从代码中调用它时期望看到的结果
为什么,为什么,为什么?
【问题讨论】:
标签: c# sql sql-server sql-function