I would like to replace all null values with DBnull in a data table

similar to:

dtCorrected = OriginDataTableVar.Clone()

dtCorrected =

(From r In dtData.AsEnumerable
let ra = r.ItemArray.Select(Function (x) If(isNothing(x) OrElse String.IsNullOrEmpty(x.ToString.Trim), DBNull.Value, x)).toArray
Select dtCorrected.Rows.Add(ra)).CopyToDataTable()
2 Likes