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.
精彩评论