Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 629
  • Last Modified:

Group Data in Dataset

I have a dataset that I populate from and SQL Server database and then add a new column to from within my code.  The purpose of that  new column is to store a value that is calculated from within my based on the current date.   I have all of this part of my coding working ok  

What I want to do now is group all of the data by the new column I added so I can use it in a report

Can this be done?  The column I want to group on is not part of the original dataset but the new column I added and the value that was stored in it.

I'm using vb.net, .NET Framework  4.0
0
Mike_Stevens
Asked:
Mike_Stevens
2 Solutions
 
CodeCruiserCommented:
You can use LINQ to do grouping. Example here

http://sharepoint-tamizha.blogspot.co.uk/2013/08/group-by-multiple-columns-in-datatable.html

You can also loop through the table and do it manually. Example here

http://sutocom.net/2013/09/04/apply-group-by-clause-on-datatable-in-c/
0
 
Jacques Bourgeois (James Burger)Commented:
You might be able to define the extra column in the query itself, as a calculated column, and perform the grouping in the query itself. Depending on the operations that you need to do, this is usually faster to do it on the server than do in code.

Then, the result of you query would already be grouped.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now