Home All Groups Group Topic Archive Search About

Get distinct values from a column in a datatable

Author
30 Jan 2006 7:27 PM
jvb
I am trying to find a way, other than iterating through every row or
requerring the database, to get the distinct values from a column in a
datatable.

Any help would be appreciated.

Thanks.

Author
30 Jan 2006 7:58 PM
AMDRIT
You will have to iterate over the rows so that you may compare  for distinct
values.  However, the logic may be prepared generically.

Each datatable has a getenumerable method. internally, it loops over the
list.  You could create a generic GetDistinctEnumerable and pass in the
datatable's enumerable.  Perhaps you could then bind your data list repeater
or datagrid to the result set.




Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1138649249.758848.164480@z14g2000cwz.googlegroups.com...
>I am trying to find a way, other than iterating through every row or
> requerring the database, to get the distinct values from a column in a
> datatable.
>
> Any help would be appreciated.
>
> Thanks.
>
Author
30 Jan 2006 8:12 PM
W.G. Ryan - MVP
I don't think you can get around iteration in one form or another, but this
should help http://support.microsoft.com/default.aspx?scid=kb;en-us;326176

Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1138649249.758848.164480@z14g2000cwz.googlegroups.com...
>I am trying to find a way, other than iterating through every row or
> requerring the database, to get the distinct values from a column in a
> datatable.
>
> Any help would be appreciated.
>
> Thanks.
>