This is the time for a small table, I think.
T-SQL type name | .NET equivalent | C# type name | DataReader method ----------------+-----------------+--------------+------------------------ FLOAT | System.Double | double | IDataReader.GetDouble() REAL | System.Single | float | IDataReader.GetFloat()
Note that GetFloat has the wrong name - it must be GetSingle , because float is a C # -specific name. For example, this does not make sense in VB.NET.
So, if the database column is of type float , read it using GetDouble , not GetFloat . Data reading methods do not perform conversions; There is a common GetValue method to get the value as an object , which can then be converted further.
By the way, this is not the only subtlety - .NET floating point types support denormalized values , while T-SQL types do not, therefore in your .NET code you can have floating point numbers that cannot be stored in the database, even if the types match up.
source share