Removing Duplicates and original in Datatable

Hi ,
I want to remove the duplicate as well as the original data row in the data table and want to retrieve the unique data. For example if my data table contains

book
note
book
pen
note

Then, I want to remove " book " and “note” as they are similar and repeated data row and want to print “pen” as it is unique one . RemoveDuplicateRows will remove the first duplicate occurrence while leaving the original. Can anyone help me out with this ?

Hello,

You can use this

dt = dt.defaultview.totable(True, “Colum1”, “Column2”).

This way you inform which columns you want and “TRUE” will remove the duplicates

1 Like

@Uthraa

Let us take you are having dataTable dta.

Now

   dtb=(From p In dta.Select
                   Where (From q In dta.Select
                               where p("Column A").ToString.Equals(q("Column A").ToString)
                               Select q).ToArray.Count<=1
                   Select p).ToArray.CopyToDataTable

Regards,
Mahesh

1 Like

Thanks fro you replies. Will work this out and get back to you guys !