Select from DataTable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew

    #1

    Select from DataTable

    I have a DataTable loaded in memory that looks like this:

    Product - Qty
    1001 - 3
    1001 - 5
    1080 - 8

    I need it like that, and I also need that data to look like this:
    Product - Qty
    1001 - 8
    1080 - 8

    Is there a way to GROUP BY Product?
    Maybe by running a select query on that DataTable, or some kind of
    DataView?

    I would prefer not to go back to the database.

    Thank you,

    Matthew

  • Marina

    #2
    Re: Select from DataTable

    The DataTable has a Compute method, that can do this on a one by one product
    basis.

    However, that's not really a good substitute for a query with a GROUP BY.

    The DataTable cannot do anything else for you - it is not an in memory
    database engine. It is just an in memory set of data.

    Your best bet is to go back to the database.

    "Matthew" <PRESENT321@gma il.com> wrote in message
    news:1124826941 .760421.202760@ g49g2000cwa.goo glegroups.com.. .[color=blue]
    >I have a DataTable loaded in memory that looks like this:
    >
    > Product - Qty
    > 1001 - 3
    > 1001 - 5
    > 1080 - 8
    >
    > I need it like that, and I also need that data to look like this:
    > Product - Qty
    > 1001 - 8
    > 1080 - 8
    >
    > Is there a way to GROUP BY Product?
    > Maybe by running a select query on that DataTable, or some kind of
    > DataView?
    >
    > I would prefer not to go back to the database.
    >
    > Thank you,
    >
    > Matthew
    >[/color]


    Comment

    • Matthew

      #3
      Re: Select from DataTable

      Oh well. I guess I can make that work.

      Thank you!

      Matthew

      Comment

      Working...