using the below expression to remove duplicates from table “ReportDT” on the basis on column “Issue Id” and
ReportDT.AsEnumerable().GroupBy(Function(i) i.Field(Of String)(“Issue Id”)).Select(Function(g) g.First).CopyToDataTable
getting the exception Unable to cast object of type ‘System.Double’ to type ‘System.String’
Can someone help ?
ReportDT.AsEnumerable().GroupBy(Function(a) a.Field(Of String)(“Issue ID”)).Select(Function(b) b.First).CopyToDataTable()
try this method!
cheers
@amangupta4644
still getting the same error
Arvind21
(Arvind A)
February 26, 2020, 10:03am
4
Hi @amangupta4644
Can u try this
ReportDT.AsEnumerable().GroupBy(Function(i) i.Field(Of Double)(“Issue Id”)).Select(Function(g) g.First).CopyToDataTable
or
ReportDT.AsEnumerable().GroupBy(Function(i) Convert.ToDouble(i(“Issue Id”))).Select(Function(g) g.First).CopyToDataTable
Hope it helps
ppr
(Peter Preuss)
February 26, 2020, 10:06am
5
@amangupta4644
Give try on
ReportDT.AsEnumerable().GroupBy(Function(a) a.(“Issue ID”).toString.Trim).Select(Function(b) b.First).CopyToDataTable()
If itnis still failing then Show US some Sample Data and give US some more Details.
The guess was about that the forced Datatype use by the field method is causing the Error from above
still the issue not resolved…tries this one too
did you try using Remove Duplicate row activity?
@amangupta4644
new_dataTable =
ReportDT .AsEnumerable().GroupBy(Function(i) i.Field(Of String)(“ Issue Id ”)).Select(Function(g) g.First).CopyToDataTable
try assigning like this and try!
cheers