Tuesday, July 13, 2010

Distinct Values from DataTable

Here is a very simple way to grab distinct values from a DataTable and throw them into another DataTable. "dt" is our original DataTable and "dt2" wants distinct person_id and person_name.

DataTable dt2 = dt.DefaultView.ToTable(true, new string[2] { "person_id", "person_name" });

No comments:

Post a Comment