This topic has not yet been rated - Rate this topic

SqlDataReader.GetFloat Method

Gets the value of the specified column as a single-precision floating point number.

Namespace:  System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)
public override float GetFloat(
	int i
)

Parameters

i
Type: System.Int32
The zero-based column ordinal.

Return Value

Type: System.Single
The value of the specified column.

Implements

IDataRecord.GetFloat(Int32)
IDataRecord.GetFloat(Int32)
Exception Condition
InvalidCastException

The specified cast is not valid.

No conversions are performed. Therefore, the data retrieved must already be a single-precision floating point number.

Call IsDBNull to check for null values before calling this method.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
sql float : CLR single or double ?
http://msdn.microsoft.com/en-us/library/ms131092.aspx says sql float => CLR Double
but
http://msdn.microsoft.com/fr-fr/library/bb386947.aspx says sql float => CLR Single or Double according to (DataType.MaximumLength < 24)

With .Net 4.0 and sql server 2008 R2, I already have got problems with mapping from "sql float" ( 8 : ie length < 24) to "CLR Single" , but it seems to be the usual implementation in Linq To SQL...

Is anyone can help me ?
Specified cast is invalid
$0The name of this method and the others could be GetAsFloat, because this method doesn't get a float. GetDouble gets a SQL float. GetSqlFloat could have been the name for it, but then it wouldn't convey the output type and it would confuse things further with the CLR SqlDouble type which is supposed to represent a SQL float. It's all very confusing really and I like to think that the people that made this bit have left Microsoft for jobs in the Bush administration. This will help with your headache: http://msdn.microsoft.com/en-us/library/ms131092.aspx$0