SqlDataReader.GetFloat

  • Thread starter Thread starter John Straumann
  • Start date Start date
J

John Straumann

Hi all:

I have a SQL Data Table with some values of type "float" (set in SQL table
design). I am trying to read the values via a SqlDataReader (this app does
not use DataGrids) and for some reason I am getting a
"Specified cast is not valid" message.

Anyone out there know wassup with that?

Thanks.

John.
 
John,

What are you trying to cast to? Are you trying to cast to double, or to
decimal? The type that is returned should be SqlFloat. If you use the
debugger, you can assign the value to an object variable, and see the type
of the object returned in the debugger.

Hope this helps.
 
John Straumann said:
I have a SQL Data Table with some values of type "float" (set in SQL table
design). I am trying to read the values via a SqlDataReader (this app does
not use DataGrids) and for some reason I am getting a
"Specified cast is not valid" message.

Anyone out there know wassup with that?

Are you trying to cast it to a float? If so, that's probably what's
wrong. Somewhat confusingly, a SQL Float corresponds to a C# double.
 
Back
Top