开发者

What specific values can a C# double represent that a SQL Server float can't?

开发者 https://www.devze.com 2023-02-01 04:04 出处:网络
I\'m getting an error when I pass a C# double into a SQL Server float parameter.I know I\'m sending in a value that the SQL Server float can\'t represent, but I can\'t figure out which one it is.So, m

I'm getting an error when I pass a C# double into a SQL Server float parameter. I know I'm sending in a value that the SQL Server float can't represent, but I can't figure out which one it is. So, my question is what values can a C# double represent that a SQL Server f开发者_StackOverflowloat can't?


IIRC the values NaN, PositiveInfinity and NegativeInfinity are not supported by SQL Server. You could check for this with the methods Double.IsNaN(...) and Double.IsInfinity(...).

Don't use == for checking, as these special values are never equal to any other value, not even themselves (e.g. NaN != NaN).


A double and a float are the same datatype. I think your error may be secondary to another issue. Perhaps your parameter is not getting passed correctly? Check the actual value of the parameter that is being passed in the data stream.

0

精彩评论

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