how to pass 0 for empty cell in datatable
for this datatable …
name | col 1 | col 2 | col 3 | col 4 | col 5 | col 6 |
---|---|---|---|---|---|---|
8-15 | 12 | 1 | ||||
3-7 | 9 | 3 | 3 | 1 | ||
1-3 | 27 | 15 | 7 | 2 | 7 | 4 |
Total | 48 | 15 | 10 | 5 | 7 | 6 |
share your sequence file.
how to pass 0 for empty cell in datatable
for this datatable …
name | col 1 | col 2 | col 3 | col 4 | col 5 | col 6 |
---|---|---|---|---|---|---|
8-15 | 12 | 1 | ||||
3-7 | 9 | 3 | 3 | 1 | ||
1-3 | 27 | 15 | 7 | 2 | 7 | 4 |
Total | 48 | 15 | 10 | 5 | 7 | 6 |
share your sequence file.
Try the below linq expression,
- Assign -> resultDataTable = (From row In dataTable.AsEnumerable()
Let newRow = row.ItemArray.Select(Function(cell) If(cell Is DBNull.Value OrElse String.IsNullOrEmpty(cell.ToString()), 0, cell)).ToArray()
Select dataTable.Rows.Add(newRow)).CopyToDataTable()
Hope it helps!!
this code is replicate error share you sequence file.
hi @domsmgtmeet22 sounds like that’s what you need.