Solved filter on a data table to read unique items

Posted on 2012-08-21
Last Modified: 2012-08-21

I usually use the following SQL statement coupled with a reader to populate an 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
                    For i As Integer = 0 To xSQLTable_Accounts.DefaultView.Count - 1
                        .Add(xSQLTable_Accounts.DefaultView.Item(i).Item("Segment 1 Desc"))
                End With
Question by:murbro
    LVL 83

    Accepted Solution

    Change this

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


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

    Then loop through dTemp

    Author Closing Comment

    Thanks very much

    Author Comment

    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!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now