Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. dataset sort and combine/consolidate

dataset sort and combine/consolidate

Scheduled Pinned Locked Moved C#
tutorialquestion
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jeweladdict
    wrote on last edited by
    #1

    I have a dataset of items (UPC, price, quantity, name) that I would like to combine based on like items. For example, all items with the same name, I would like to combine so that the quantity and prices are changed accordingly. Are there any built in functions that will let me do this? Or do I have to create a routine which will sort the dataset, create a new set, and then go through the old dataset and combine like items and then add to the new dataset? thanks!

    J N 2 Replies Last reply
    0
    • J jeweladdict

      I have a dataset of items (UPC, price, quantity, name) that I would like to combine based on like items. For example, all items with the same name, I would like to combine so that the quantity and prices are changed accordingly. Are there any built in functions that will let me do this? Or do I have to create a routine which will sort the dataset, create a new set, and then go through the old dataset and combine like items and then add to the new dataset? thanks!

      J Offline
      J Offline
      jeweladdict
      wrote on last edited by
      #2

      I guess this would be more of a datarow combining/merging question./..

      1 Reply Last reply
      0
      • J jeweladdict

        I have a dataset of items (UPC, price, quantity, name) that I would like to combine based on like items. For example, all items with the same name, I would like to combine so that the quantity and prices are changed accordingly. Are there any built in functions that will let me do this? Or do I have to create a routine which will sort the dataset, create a new set, and then go through the old dataset and combine like items and then add to the new dataset? thanks!

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        Hello

        jeweladdict wrote:

        Are there any built in functions that will let me do this?

        Well, maybe you're talking about Stored Procedures? Anyway, here is an approach to do something like what you want -even though I don't like it but I can't really think of something better-. 1- Make a datagridview and feed it with your table 2- Sort it according by the name -if that's what you want 3- Iterate through the rows comparing each row with its previous one -except the first row of course- 4- Find similar rows and combine their values, then delete the second one NB. You don't have to make the DataGridView visible to the user Please, if someone has a better approach post. I believe there should be a better way. but this should work! Regards:rose:

        J 1 Reply Last reply
        0
        • N Nader Elshehabi

          Hello

          jeweladdict wrote:

          Are there any built in functions that will let me do this?

          Well, maybe you're talking about Stored Procedures? Anyway, here is an approach to do something like what you want -even though I don't like it but I can't really think of something better-. 1- Make a datagridview and feed it with your table 2- Sort it according by the name -if that's what you want 3- Iterate through the rows comparing each row with its previous one -except the first row of course- 4- Find similar rows and combine their values, then delete the second one NB. You don't have to make the DataGridView visible to the user Please, if someone has a better approach post. I believe there should be a better way. but this should work! Regards:rose:

          J Offline
          J Offline
          jeweladdict
          wrote on last edited by
          #4

          that works like a charm. Thanks!

          N 1 Reply Last reply
          0
          • J jeweladdict

            that works like a charm. Thanks!

            N Offline
            N Offline
            Nader Elshehabi
            wrote on last edited by
            #5

            Hello An Even much better approach is to use the DataView class instead of a DataGridView!! Sorry that such a simple solution didn't cross my mind:-O, I've been awake for almost two days now!! Regards:rose:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups