Unable to cast object of type ‘System.Double’ to type ‘System.String’ in expression

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

issue still getting the same error

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 :slight_smile:

@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