Implementing Group By in a DataSet in VB.NET
We know a DataSet does not support GROUP BY and recently I needed GROUP BY in one of my applications. This attached class shows how to implement GROUP BY in a DataSet.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: Implementing Group By in a DataSet in VB.NET

Thomas ErbachereditedPosted Nov 18, 2012, 10:43 AM ESTEdited Nov 18, 2012, 10:47 AM EST
Insert this for avg Case "avg"DestRow(Field.FieldAlias) = Avg(DestRow(Field.FieldAlias), SourceRow(Field.FieldName)) and: Public Function Avg(ByVal a As Object, ByVal b As Object) As Object'Averages two values - if one is DBNull, then returns the other'' if (a is DBNull)' return b;' if (b is DBNull)' return a;' Dim dblA As Double = 0.0Dim dblB As Double = 0.0Double.TryParse(a.ToString(), dblA)Double.TryParse(b.ToString(), dblB)Return ((Convert.ToDouble(dblA) + Convert.ToDouble(dblB)) / 2)End Function
ONPRPosted Jun 8, 2010, 1:36 AM EDT
Thank you for great class! But why average (avg) operator is missed?
tArun cHatterjeePosted Apr 29, 2010, 4:37 AM EDT
many thanks
kumar rajaPosted Aug 29, 2009, 2:44 AM EDT
Hi, I am developing one windows application in vb.net which creates digitally signed pdf. I am getting one exception (System.OutOfMemoryexception) after generating some (1200) pdf. I've properly closed all objects and flushed the file stream which i've used in the application. But still i am getting the error. Any Idea?
kumar rajaPosted Aug 28, 2009, 11:05 PM EDT
Hi Mahesh, I got it from InsertGroupByInto. Its working fine. Thank you.
kumar rajaPosted Aug 28, 2009, 10:54 PM EDT
Dear Mahesh, I'd tried to use your DatasetHelper. Called CreateGroupByTable by passing table name, Datatable and field which datatable to be group by but it returns me only datatable with column name which i'd passed for groupby and without data. Please clarify ... Thank you for providing such usefull article.
mhaey gulanesPosted Mar 12, 2009, 9:54 PM EDT
any other?