Solved

Group Data in Dataset

Posted on 2014-01-24
2
545 Views
Last Modified: 2014-01-29
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
Comment
Question by:Mike_Stevens
2 Comments
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 39806920
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
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39807817
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now