开发者

SQL DateTimes From C# Linq to Stored Procedure

开发者 https://www.devze.com 2022-12-11 00:28 出处:网络
I have a compl开发者_如何学Cex sql query that I have in a stored procedure and am calling from C#.

I have a compl开发者_如何学Cex sql query that I have in a stored procedure and am calling from C#.

The procedure requires a date-time which I pass in as DateTime object from c#, the problem seems to occur with the format of the date. If I change the parameter to string and pass it in as 'yyyy-MM-dd' it works fine.

Is there anyway to use the datetime object?


Are you setting the stored procedure parameter SqlDbType property to SqlDbType.DateTime?

SqlParameter p = sqlCmd.Parameters.Add("@date", System.Data.SqlDbType.DateTime);

// set value
p.Value = DateTime.Now;

(update)

Also, I found this related question.

0

精彩评论

暂无评论...
验证码 换一张
取 消