Casting Object to Float error

  • Thread starter Thread starter Steve Wasser
  • Start date Start date
S

Steve Wasser

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!
 
Back
Top