Private Function GetChartData(ByVal theCommand As SqlCommand) As DataTableDim d As SqlDataAdapter = New SqlDataAdapter(theCommand)Dim t As DataTable = New DataTable("ChartData")d.Fill(t)Return tEnd Function
This topic is a continuation of Creating a Drilldown Chart (Part 3 of 5).
For this particular walkthrough, the code and logic for data access is within the user interface. In a real-world enterprise application, this should be handled by the Data Access Layer and / or business objects that reside in the Business Logic Layer.
The following method accepts the SqlCommand that was built in the BuildChart method and returns a DataTable that contains the schema and data for a particular drill level. In Visual Basic:
Private Function GetChartData(ByVal theCommand As SqlCommand) As DataTableDim d As SqlDataAdapter = New SqlDataAdapter(theCommand)Dim t As DataTable = New DataTable("ChartData")d.Fill(t)Return tEnd Function
In C#:
private DataTable GetChartData(SqlCommand theCommand){SqlDataAdapter d = new SqlDataAdapter(theCommand);DataTable t = new DataTable("ChartData");d.Fill(t);return t;}