ASP.net filter on a data table to read unique items

Hi

I usually use the following SQL statement coupled with a reader to populate an ASP.net DropDownList. In my latest solution I am trying to read the same items using a filter.
I'm not quite sure how to use Distinct or create get unique items from the following code  
How would I adjust the following line marked XXXX  ?

  xSQLTable_Accounts.DefaultView.RowFilter = "[Segment 1 Desc]=*"  'XXXX

                With Me.Category1.Items
                    .Clear()
                    For i As Integer = 0 To xSQLTable_Accounts.DefaultView.Count - 1
                        .Add(xSQLTable_Accounts.DefaultView.Item(i).Item("Segment 1 Desc"))
                    Next
                End With
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Change this

xSQLTable_Accounts.DefaultView.RowFilter = "[Segment 1 Desc]=*"  'XXXX

to

Dim dTemp As DataTable = xSQLTable_Accounts.DefaultView.ToTable(True, "[Segment 1 Desc]")

Then loop through dTemp
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Minor alteration: had to take square brackets out to get it to work
  Dim dTemp As DataTable = xSQLTable_Accounts.DefaultView.ToTable(True, "Segment 1 Desc")
Thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.