2
Reply

InvalidCastException was unhandled - Specified cast is not v

Sairam Soham

Sairam Soham

Jun 14 2015 9:18 PM
473

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)