473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SqlDataReader.GetFloat

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.
Nov 15 '05 #1
3 10062
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Straumann" <js********@cogeco.ca> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 15 '05 #2
John Straumann <js********@cogeco.ca> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
For SOME strange reason, GetSqlDouble worked...

John.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
John Straumann <js********@cogeco.ca> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
4
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data...
1
by: me | last post by:
Why is SqlDataReader not present in visual studios Toolbox->Data where I find components like DataSet? Most examples in books and in vs.net are based on datasets but using disconnected tables seems...
4
by: mimi | last post by:
Hi Please help me out, I can't find a way to close a sqldatareader when error occur at statement cmd.ExecuteReader(). I can't close it in catch because it is local in try scope and I can't...
3
by: Dom | last post by:
Still teaching myself about SQLDataReader and associated classes. I have to say, the new HELP screens from MS are just about useless!! Let's assume I have just read some records from a table...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.