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 はこのレベルでは null でなければなりません
'コマンドをビルドします
          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
'このドリル レベルのために Chart プロパティを設定します
          Me.ultraChart1.ChartType = ChartType.BarChart3D
          Me.ultraChart1.Legend.Visible = True
'DataSource を設定します
          Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand)
'このレベルのためにリンク ラベルを設定します
          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
'このレベルのために UI ラベルを設定します
          Me.lbl1.Enabled = True
          Me.lbl2.Enabled = False
          Me.lbl3.Enabled = False
     'レベル 2:実際の Orders PER 顧客を取得できます
    Case 2
'コマンドをビルドします
          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)
'このドリル レベルのために Chart プロパティを設定します
          Me.ultraChart1.ChartType = ChartType.PieChart3D
          Me.ultraChart1.Legend.Visible = True
'DataSource を設定します
          Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand)
'このレベルのためにリンク ラベルを設定します
          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
'このレベルのために UI ラベルを設定します
          Me.lbl1.Enabled = False
          Me.lbl2.Enabled = True
          Me.lbl3.Enabled = False
'コマンドをビルドします
    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)
'このドリル レベルのために Chart プロパティを設定します
          Me.ultraChart1.ChartType = ChartType.CylinderColumnChart3D
          Me.ultraChart1.Legend.Visible = True
'DataSource を設定します
          Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand)
'このレベルのためにリンク ラベルを設定します
          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
'このレベルのために UI ラベルを設定します
          Me.lbl1.Enabled = False
          Me.lbl2.Enabled = False
          Me.lbl3.Enabled = True
    Case Else
          Throw New ApplicationException("Unhandled Drill Level")
    End Select
End Sub