Or if the number of rows is less then you can use a for loop and a
hashtable. As you loop insert into hashtable. If you find a duplicate ignore
the key. At the end you can just get the count from hashtable.
-SP
Miha Markic said:
Hi,
I would go with a simple foreach (DataRow row in table.Rows) loop.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com www.rthand.com
M K said:
I have a Datatable in a DataSet that for one part of the process I need to
know the count of DISTINCT/UNIQUE values in one column. How can I achieve
this.
Well, yes, doing it manually was what i was thinking.
Storing unique value and its count (if you want to count the key occurences
also) in a hashtable is a good one.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com www.rthand.com
Or if the number of rows is less then you can use a for loop and a
hashtable. As you loop insert into hashtable. If you find a duplicate
ignore
the key. At the end you can just get the count from hashtable.
-SP
Miha Markic said:
Hi,
I would go with a simple foreach (DataRow row in table.Rows) loop.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com www.rthand.com
M K said:
I have a Datatable in a DataSet that for one part of the process I need to
know the count of DISTINCT/UNIQUE values in one column. How can I achieve
this.
The .net framework's DataTable's select method only provide some very basic
semantics, which haven't include the "unique item count" function, you can
check all the supported semantics in the following link:
If you do want to do the unique item query, I think you should consider
other members suggestion that manually loop through the items and count the
distinct ones.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.