Unique records from DataTable

  • Thread starter Thread starter Soren Staun Jorgensen
  • Start date Start date
S

Soren Staun Jorgensen

Hi,

How do i get unique values of a specific column in a DataTable - i dont
surpose i ts possible to use something like "select distinct" as in regular
SQL ??

Soren
 
unfortunately, you can't do a select distinct. the only alternative
i've seen is to loop through the rows and add the columns value to a
hashtable.

Hashtable ht = new Hashtable();

foreach(DataRow dr in table.Rows)
{
if(!ht.Contains(dr["ColumnName"]))
{
ht.Add(dr["ColumnName"], null);
}
}
 
Back
Top