REMOVING DUPLICATIONS FROM A DATATABLE

My developer friend is google and my best friend is stackoverflow.

Being a bit lazy but more importantly trusting other more knowledgable IT colleagues, I came across this bit of code.

FindDups.PNG

You enter the call with the following code

Array.PNG

So far so good. The good thing about this code is that it allows defining unique keys with multiple columns (but it was written in 2004).

Looking at stack I found this

RemoveDuplicateRows.PNG

Much better but only allows duplicates from a single column which has been defined. The above code is simple and quick and I was about use it as a base when out of nowhere this appeared.

removeduplicatesDT.PNG

This is genius. The strColumns defines all the columns you wish to import into your new DataTable otherwise it won't import them. The issue with this of course is that all your columns need to be unique and luckily was in my case.

So my advice to you is don't just pick the first google/stack which you see, look around and you might find something more interesting.

Previous
Previous

SO YOU WANT TO CODE?