Tuesday, August 12, 2008

Find distinct value from DataSet/DataTable in .NET

Suppose you have dataset that contain data in following manner

ID Name Country
----------------------------
1 X USA
2 Y INDIA
3 Z INDIA
This is a DataTable name EmpInfo.

Now you want to select distinct country value from above table.

DataTable country = EmpInfo.DefaultView.ToTable(true,"Country");

Now country datatable contain distinct country value from EmpInfo Table.

You get more information from following link.
http://msdn.microsoft.com/en-us/library/wec2b2e6.aspx

No comments: