I would like to replace all null values from a data table as DBnull.value the following link was to just to replace only one column. I used to write with different column names, however this is not possible since the number of columns more that 25 columns and it becomes a challenge, so appreciate your support with an extension of the link below.
can this be enhance on this code would be much easier.
in_dt_GrBlankAgeingDT.AsEnumerable.ToList.ForEach(Sub(row)
If(IsNothing(row(“GRN_DATE”)) Or (String.IsNullOrEmpty(row(“GRN_DATE”).tostring.Trim))) Then
row(“GRN_DATE”) = DBNull.Value
End If
End Sub
)
in_dt_GrBlankAgeingDT.AsEnumerable.ToList.ForEach(Sub(row)
For Each d In Enumerable.Range(0,in_dt_GrBlankAgeingdt.Columns.Count)
If(IsNothing(row(d)) Or (String.IsNullOrEmpty(row(d).tostring.Trim))) Then
row(d) = DBNull.Value
End If
Next
End Sub
)
(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()