By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,567 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,567 IT Pros & Developers. It's quick & easy.

Unique records from DataTable

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
http://support.microsoft.com/default...b;EN-US;326176
"Soren Staun Jorgensen" <no@spam.com> wrote in message
news:OZ*************@TK2MSFTNGP12.phx.gbl...
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

Nov 15 '05 #2

P: n/a
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);
}
}

On Wed, 11 Feb 2004 21:52:33 +0100, "Soren Staun Jorgensen"
<no@spam.com> wrote:
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


Nov 15 '05 #3

P: n/a
Nice, thanks...

Soren

"William Ryan eMVP" <do********@comcast.nospam.net> skrev i en meddelelse
news:e6****************@TK2MSFTNGP10.phx.gbl...
http://support.microsoft.com/default...b;EN-US;326176
"Soren Staun Jorgensen" <no@spam.com> wrote in message
news:OZ*************@TK2MSFTNGP12.phx.gbl...
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


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.