Results 1 to 3 of 3

Thread: [2005] Distinct values in DataTable

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    [2005] Distinct values in DataTable

    Hi,
    I'm looking for a very quick method of determing distinct values in a DataTable.
    The application is streamreading a text file, and populates a table.
    The table could end up being huge, and so this can have an adverse effect on performance, so I'm looking to implement the fastest possible method of getting the distinct ProductIDs from the table.
    Looping through the table and putting the ProductID values into an array, and then checking to see if the value is contained within the array before adding a new value seems to be fairly good.
    Sorting the table in a DataView and looping through seems slower.
    I've come across a page on MSDN which seems old-ish.
    Are there any other solutions that I could consider? I'd like to think that I could do something "at source", and so when the data is read in, and stuffed into a DataRow, do something with it at that point?
    Any suggestions would be appreciated.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2005] Distinct values in DataTable

    I'd actually give that MSDN article a shot. I imagine that would be better suited to searching for your distinct values rather than using an Array.

    Good luck.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [2005] Distinct values in DataTable

    Yeah - I'll give it a try - but was hoping for something clever that didn't have to loop through the data.
    Thanks anyway.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

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