How to select distinct rows in a datatable and store into an array

Ahmed Atia picture Ahmed Atia · Jul 29, 2009 · Viewed 610.9k times · Source

I have a dataset objds. objds contains a table named Table1. Table1 contains column named ProcessName. This ProcessName contains repeated names.So i want to select only distinct names.Is this possible.

  intUniqId[i] = (objds.Tables[0].Rows[i]["ProcessName"].ToString());

Answer

Thomas Levesque picture Thomas Levesque · Jul 29, 2009
DataView view = new DataView(table);
DataTable distinctValues = view.ToTable(true, "Column1", "Column2" ...);