AnonymousCow
AnonymousCow

Reputation:

Sql server real datatype, what is the C# equivalent?

What is the C# equivalent to the sql server 2005 real type?

Upvotes: 57

Views: 56119

Answers (7)

Guzumba
Guzumba

Reputation: 111

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.

Upvotes: 5

George Nelson
George Nelson

Reputation: 31

the answer is Single or float. (depending on style.) this is like the difference between String and string [source: ReSharper code suggestion "use type keyword" when using Single. it suggested using float.

Upvotes: 3

Aman G
Aman G

Reputation: 61

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

Upvotes: 3

prisznitz
prisznitz

Reputation: 11

in my project (acces -> firebird and ms sql -> c#) is real defined like single precission float point number...so I used float and everything is OK

Upvotes: 1

msbyuva
msbyuva

Reputation: 3615

Double can be used as the .NET Equivalent Datatype for Real Datatype of SQL Server

Double gets the exact value with out Rounding

Upvotes: 7

msbyuva
msbyuva

Reputation: 3615

Single is not the correct answer as it rounds the decimal part.. For instance 2.0799999 will be converted to 2.08. If there are no constraints regarding the rounding then it should be good.

Upvotes: 9

YonahW
YonahW

Reputation: 16520

it is a Single

see here for more info on SQL Server to .Net DataTypes

Upvotes: 86

Related Questions