Solved

Group Data in Dataset

Posted on 2014-01-24
2
551 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

932 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

16 Experts available now in Live!

Get 1:1 Help Now