Unique values from dataset?

  • Thread starter Thread starter Marty McDonald
  • Start date Start date
M

Marty McDonald

The dataset was populated with "Select category, detail, information from
tblmain".
Now, I'd like to populate a System.Windows.Forms.ListBox with distinct
"category" fields, i.e. each category is listed in the listbox only once.
I'd like to use the dataset I already have without going to the server
again. Would DataView play a part in this? Thanks for any info... Marty
 
Hi Marty,

The DataView class didn't support a filter with Distinct. You may consider
set the listbox' items by code, for example:


For i = 0 To DataSet11.Table1.Rows.Count - 1


If Not
(ListBox1.Items.Contains(DataSet11.Table1.Rows(i)("category"))) Then
ListBox1.Items.Add(DataSet11.Table1.Rows(i)("category"))

End If


Next i

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Thanks for the information. I just thought of another idea too... I can
load the dataset into XML, then I can use xpath or DOM to get unique values.
 
Back
Top