Could anyone be so kind as to tell me why, when reading from an Oracle database, I get the following error:
Object of type 'System.Decimal' cannot be converted to type 'System.Int32'.
It happens when I pass a variable (oValue) of type object into a function. I’ve tried casts, converts, unchecking, truncating, pretty much the whole sha-bang, and nothing works. Here’s where the code fails:
PropertyInfo property = Objects[0].GetType().GetProperty(sProperty);
property.SetValue(Objects[0], oValue, null);
Any help would be much appreciated.
EDIT: Here’s what I’ve tried so far:
(int)oValue, Convert.ToInt32(oValue), Math.Truncate((decimal)ovalue), Decimal.Truncate((decimal)oValue), Decimal.ToInt32((decimal)oValue), and using unchecked {}
Put:-