Sairam Soham

Sairam Soham

  • NA
  • 47
  • 28.3k

InvalidCastException was unhandled - Specified cast is not v

Jun 14 2015 9:18 PM

I am adding data in the datatable using the following code


            foreach (DataRow row in dtRevClassAvgByDate.Rows)
            {
                dtMeter.Rows.Add(meterId + "_EndPoint:1-Electric", 
                Global.ChannelIdType,
                Global.MarketType,             
                ((DateTime)row["DayAndHour"]).ToString("yyyy-MM-dd HH:mm"),
                float.Parse(row["AVG_kWH_Del"].ToString()) * ratioAmrToAmi,
                  Global.IntervalLength,
                 0, 0, 0, 0, 0, 0, 0);
            }

The following code is throwing Specified cast is not valid exception

float.Parse(row["AVG_kWH_Del"].ToString()) * ratioAmrToAmi,

Any thoughts?

 


Answers (2)