How to get unique entries from SQL database

jeshra_279

Member
Joined
Oct 28, 2009
Messages
6
Programming Experience
3-5
Hi,
I have a datagridview1 column "Name", which has collections of names and some are repetitive; e.g.
"Name"
-------
ram
shyam
ram
ram
raj
shuk
shuk

So, in the above "Name" column, there are repeatation of names. I want to do this:

1) read the repetitive name as a single, e.g. "ram", "shuk"
2) store them in a array of string;
3) finally the array should be like this : arr(1) = "ram", arr(2) = "shyam", arr(3)="raj",arr(4)="shuk" .

So in arrays I have finally stored the repetitive names as once.

Now I want to copy these array entries into rows of another datagridview2 whose column name is "Final Name".

Can someone help me by providing a piece of code?

Thanks
R.S.
 
You do not mention what the original datasource of the datagridview is, and this will affect your solutions. Here is a pretty simple start if your datasource is a DataTable object

VB.NET:
Expand Collapse Copy
        Dim dv As New DataView(DirectCast(dgvStrings.DataSource, DataTable))
        Dim dtSingleNames As DataTable = dv.ToTable("SingleNames", True)
 
Back
Top