0
votes

I created a FastReport report and sometimes an error occurrs when I try to preview it.

The report is incorrect:

Invalid conversion of "System.Int32" to "My.Namespace.MyCustumEnum".

I have SQL queries and the result is automatically converted to DataTables. I cast Enum values to int, even when i don't do it that still occurs.

1
This is moaning about an attempt to implicitly cast an int to an enum. Where in your code are you expecting to set a value to an enum? Are you populating an object from the row in the DataTable?Kell
No, I don't use the enum at all i just check the value like "2".Equals(enumValue)horotab
try using ((int)enumValue) == 2Kell

1 Answers

0
votes

Ok, I've solved this case. There are different problems I've found.

  1. In FastReport in the Datasource Explorer I have set the Type of that column to int32. (this is the critical step to solve the error)
  2. As said I have logic that will convert enums to int when creating the DataSet. Nullable<> enums did not got parsed. I fixed this as well so this problem should not occurr again when adding more tables.