Splitting up dataset into part

I have a sql result (from 3 tables) that looks like this:

|..OrderID..|..SupplierID..|..Quantity..|..UserID..|..ProductID..|
+--+++-+--+
|......1.......|..........2.........|......10......|.......3.....|.........8........|
|......1.......|..........2.........|.......5.......|.......3.....|.........7........|
|......2.......|..........2.........|......15......|.......1.....|.........8........|
|......3.......|..........3.........|.......1.......|......15....|........16.......|
+--+++--+-+

Based on this I want to send emails to the suppliers containing the orders

- An email can only contain an order from 1 UserID

So based on this set I would send out 3 emails

1) Order for SupplierID 2 with productID's 8 and 7 for UserID 3
2) Order for SupplierID 2 with productID 8 for UserID 1
3) Order for supplierID 3 with productID 16 for UserID 15

How do go from that resultset (dataset,datagrid,...?) to seperate results (dataset, datagrid...?) so i can send out the emails... In other words how do I go from the table to those 1), 2) and 3) results...?

(I would prefer code examples is vb.net)

[1138 byte] By [codefund.com] at [2007-12-16]
# 1
this is pseudo-code, but something like it should work.

Dim ProductList As New ArrayList()
Dim LastUserID As String = String.Empty
Dim i As Integer

With DataSet.Tables("MyTable").Rows
For = 0 To .Count - 1
With .Item(i)
ProductList.Add(.Items("ProductID"))

If .Items("UserID") <> LastUserID Then
SendEmail(.Items("UserID"), ProductList)
ProductList.Clear()
End If

LastUserID = .Items("UserID")
End With
Next
End With

Private Sub SendEmail(ByVal UserID As Integer, ByVal List As ArrayList)
'write code here to send e-mail out
'the List variable will hold all the Product ID's for the current user
End Sub

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...