System.InvalidCastException: Conversion from type 'DBNull' to type 'Integer' is not valid


#1

I have excel sheet which has few columns (meeting room, capacity, number of projector). The projector field is null if there is no projector.
I need to get the maximum number of projector. I am using UIPath 2017 and can get it successfully in Assign activity Convert.ToInt32(Master_DT.AsEnumerable().Max(Function(row) cint(row(“No. of Projector”)))) or by Convert.ToInt32(Master_DT.AsEnumerable().Max(Function(row) row(“No. of Projector”))).
But whenever there is a single record with blank projector, this assign gives error. I can filter the NotNull data into another DataTable and then get max from another DataTable. But I believe there might be a way to use if(null,0) in Convert.ToInt32(Master_DT.AsEnumerable().Max(Function(row) cint(row(“No. of Projector”)))) statement or some better way.

Anyone has any idea pls.