What is the C# equivalent to the sql server 2005 real type?
-
1Voted down because this answer is flawless and it has been on here for 13 days.Pittsburgh DBA– Pittsburgh DBA2008-10-06 22:27:15 +00:00Commented Oct 6, 2008 at 22:27
-
9Is there a way for the community to accept answers to abandoned questions, other than merely voting for them?dotancohen– dotancohen2012-02-21 18:42:13 +00:00Commented Feb 21, 2012 at 18:42
Add a comment
|
7 Answers
it is a Single
see here for more info on SQL Server to .Net DataTypes
9 Comments
Pittsburgh DBA
Why was this answer not accepted? This is not how the community should be working. Too many questions are going weeks with no accepted answer.
Sean Hanley
Who cares? The author didn't care to bother, but we as the community don't need their blessing to see and influence the "best" answer.
Maxime Labelle
Single looses precision. Double should be a more appropriate candidate.
Max Rios
However I used always double due to precision minor issues. It's correct Single is the exact one but I had some problems with that type.
IAmJersh
@Rich
float is Single. Same as int being Int32 or long being Int64, it's just a shorthand alias. |
Double can be used as the .NET Equivalent Datatype for Real Datatype of SQL Server
Double gets the exact value with out Rounding
2 Comments
Leonardo
The correct type for double data type in .NET Framework is float, you probably may get an excepction in execution time as I'm having at this moment.
barrypicker
@Leonardo - a C# struct 'System.Double' is the same as the intrinsic type 'double', not float as your comment suggests.
The answer is Single. If you use double and your SQL field is type real it will error out. I tested this myself and confirmed.
1 Comment
kappadoky
float in C# = Single, it's just a synonym (like bool and Boolean)
Its Equivalent is Single. Single is A floating point number within the range of -3.40E +38 through 3.40E +38.
Here is the latest from MSDN describes all SqlDbType and C# Equivalents