Private Sub BuildChart(ByVal FieldValue As String) Dim theCommand As SqlCommand = New SqlCommand theCommand.Connection = Me.sqlConnection1 theCommand.CommandType = CommandType.Text Dim s As String = String.Empty Select Case _currDrill Case 1 'theChartInfo should be null at this level 'Build the command s += " select TOP 10 a.customerID as 'Customer', count(b.OrderID) as 'Order Count' " s += " FROM " s += " Customers a, Orders b " s += " WHERE a.CustomerID = b.CustomerID " s += " GROUP BY a.CustomerID " s += " ORDER BY 2 DESC " theCommand.CommandText = s 'Set Chart properties for this drill level Me.ultraChart1.ChartType = ChartType.BarChart3D Me.ultraChart1.Legend.Visible = True 'Set DataSource Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand) 'Set link labels for this level Me.lnk1.Text = "Root" Me.lnk1.Enabled = False Me.lnk1.Visible = True Me.lnk2.Enabled = False Me.lnk2.Visible = False Me.lnk3.Enabled = False Me.lnk3.Visible = False 'Set the UI labels for this level Me.lbl1.Enabled = True Me.lbl2.Enabled = False Me.lbl3.Enabled = False 'Level 2: We can get the actual Orders PER customer Case 2 'Build the command s += " select TOP 10 CONVERT(VARCHAR(10), a.OrderID) as 'Order ID', count(b.OrderID) as 'Line Items' " s += " FROM Orders a, [Order Details] b " s += " WHERE a.OrderID = b.OrderID AND " s += " a.CustomerID = @CustomerID " s += " group by a.OrderID order by 2 DESC " theCommand.CommandText = s theCommand.Parameters.Add("@CustomerID", FieldValue) 'Set Chart properties for this drill level Me.ultraChart1.ChartType = ChartType.PieChart3D Me.ultraChart1.Legend.Visible = True 'Set DataSource Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand) 'Set link labels for this level Me.lnk1.Enabled = True Me.lnk1.Visible = True Me.lnk2.Text = FieldValue Me.lnk2.Enabled = False Me.lnk2.Visible = True Me.lnk3.Enabled = False Me.lnk3.Visible = False 'Set the UI labels for this level Me.lbl1.Enabled = False Me.lbl2.Enabled = True Me.lbl3.Enabled = False 'Build the command Case 3 s += " select a.ProductName as 'Product', b.Quantity as 'Quantity' " s += " FROM Products a, [Order Details] b WHERE a.ProductID = b.ProductID " s += " AND b.OrderID = @OrderID ORDER BY b.Quantity ASC" theCommand.CommandText = s theCommand.Parameters.Add("@OrderID", FieldValue) 'Set Chart properties for this drill level Me.ultraChart1.ChartType = ChartType.CylinderColumnChart3D Me.ultraChart1.Legend.Visible = True 'Set DataSource Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand) 'Set link labels for this level Me.lnk1.Enabled = True Me.lnk1.Visible = True Me.lnk2.Enabled = True Me.lnk2.Visible = True Me.lnk3.Text = FieldValue Me.lnk3.Enabled = False Me.lnk3.Visible = True 'Set the UI labels for this level Me.lbl1.Enabled = False Me.lbl2.Enabled = False Me.lbl3.Enabled = True Case Else Throw New ApplicationException("Unhandled Drill Level") End Select End Sub