Public Class BL Dim Orders As ArrayList Dim NWsource As String = "C:\Northwind.mdb" Public Function getOrders() As ArrayList Try Dim ConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" ConnStr += NWsource Dim ObjConn As New OleDb.OleDbConnection(ConnStr) Dim dt As New DataTable Dim SqlStr As String = "select OrderID, count(*) as CT, sum(Unitprice * Quantity) as PT from [Order Details] " SqlStr += "group by OrderID" Dim ObjCmmd As New OleDb.OleDbCommand(SqlStr, ObjConn) Dim ObjDA As New OleDb.OleDbDataAdapter(ObjCmmd) ObjDA.Fill(dt) ' create a list of products Orders = New ArrayList Dim orow As DataRow ' fill the product array with each row in the dataset For Each orow In dt.Rows ' calculate discount, shipping, etc. Dim OrderID As Integer = orow("OrderID") Dim PreTotal As Double = orow("PT") Dim NItems As Integer = orow("CT") Dim Discount As Double = 0 Dim Shipping As Double = 0 Dim OrderTotal As Double = 0 Shipping = 0.1 * PreTotal If (NItems >= 3 And NItems < 5) Then Discount = 0.1 * PreTotal ElseIf (NItems >= 5) Then Discount = 0.15 * PreTotal Shipping = 0 End If OrderTotal = PreTotal - Discount + Shipping Dim o As New Order(OrderID, NItems, PreTotal, Discount, Shipping, OrderTotal) Orders.Add(o) Next ' now get the price associated with each order Return Orders Catch ex As Exception MessageBox.Show("Exception: " + ex.Message) End Try End Function End Class