Find duplicates in DataTable object (VB.Net)

Hi.

I have a datatable (not a database table just the object datatable in VS.Net) (Dim dt as Datatable)

this datatable has 10 columns call them C1, C2, C3 ... C10

I like to check if there are any records in this table that has the same values in C1 C2 and C3 and then sort them out to another table.

The data is read from a CSV file and not a databse so I can't solve this in a database I nned to do it with code.

So I need one table with all the data that has no duplicate
and the other with all dupilcates

Ex

there are two rows that has same data on C1,C2 and C3, these TWO rows go to duplicatesTable the other rows go to DistinctTable.

How can I solve this..

thx guys.
LVL 1
AWestEngAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SanclerCommented:
Something like this?

        Dim CountOfRows As Integer
        Dim dtDistinct As DataTable = dtSource.Clone
        Dim dtDuplicates As DataTable = dtSource.Clone
        For Each dr As DataRow In dtSource.Rows
            CountOfRows = dtSource.Compute("Count(C1)", "C1 = " & dr("C1") & " AND C2 = " & dr("C2") & " AND C3 = " & dr("C3"))
            If CountOfRows > 1 Then
                dtDuplicates.Rows.Add(dr.ItemArray)
            Else
                dtDistinct.Rows.Add(dr.ItemArray)
            End If
        Next

Substitute your table name for dtSource.

Roger
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AWestEngAuthor Commented:
I get a syntax error missing operand after 11-operand
0
AWestEngAuthor Commented:
found it.. missing ' ' Thx man works perfect...
0
jbogart23Commented:
Where was the missing '' ??? I'm getting same error, not seeing it

_dt.Compute("Count(DOB)", "DOB = " & dr("DOB") & " AND First Name = " & dr("First Name") & " AND Last Name = " & dr("Last Name"))
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.