Results 1 to 2 of 2

Thread: Distinct on a datatable

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Port Huron, Michigan
    Posts
    20

    Distinct on a datatable

    I need to run this:

    Select Distinct(Role) From Member

    on a datatable I loaded from an XML file. How do I do this when I am not running the database on a sql server to run the statement on, I tried the filter property of the dataview but that is only for the statements in the WHERE clause of a sql statement.

    Chris

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Try this link (its in c#, but if you need the VB code, i translated it below)

    http://www.mastercoder.net/viewtopic.php?t=44

    VB Code:
    1. Dim distinctVal As Integer = 0
    2. Dim row As DataRow
    3. For Each row in testDT
    4. If distintVal != row("column")
    5. newTable.AddRow(row)
    6. distintVal = row("column")
    7. End If
    8. Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width