this error keeps showing on this line of code
ApplicantSett.Nationality1 = IIf(IsDBNull(ds.Tables("Applicant").Rows(i)("Nationality1").ToString) Or IsNothing(ds.Tables("Applicant").Rows(i)("Nationality1").ToString),
Nothing, CInt(ds.Tables("Applicant").Rows(i)("Nationality1").ToString))
the variable Nationality1 is an Integer and it is null in the database so it is not converting. what should I do?
tostring, in essential trying to match astringwith aninteger. ParseNationality1to an integer in stead of doingtostringToStringwhen checking bothDBNull&Nothingconditions:IIf(IsDBNull(ds.Tables("Applicant").Rows(i)("Nationality1")) Or IsNothing(ds.Tables("Applicant").Rows(i)("Nationality1")), Nothing, CInt(ds.Tables("Applicant").Rows(i)("Nationality1").ToString)).IsDbNullon aToStringvalue is wrong: The ToString has converted a possible DbNull value to an empty string, which is not DbNull anymore. So this will always return False. Solution: remove the .ToString.