By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,470 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,470 IT Pros & Developers. It's quick & easy.

Casting Object to Float error

P: n/a
Hi. What am I doing wrong:

foreach (DataRow dr1 in MyTable1.Rows)
{

reg[count] = (float)dr1["REG"];
prem[count] = (float)dr1["PREM"];
die[count] = (float)dr1["DIESEL"];
eth[count] = (float)dr1["ETH"];
term[count] = reg[count]+prem[count]+die[count]+eth[count];
count++;
}

Uh oh. Specified cast is not valid. Do I have to box? I'm trying to cast an
object (pulled by SQL) to a float. I know, ref to val breach of etiquette.

Thanks!

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.