Imports DataConnection Imports InfoSoftGlobal Partial Class DBExample_BasicDBExample Inherits System.Web.UI.Page Public Function CreateChart() As String 'In this example, we show how to connect FusionCharts to a database. 'For the sake of ease, we've used an Access database which is present in '../App_Data/FactoryDB.mdb. It just contains two tables, which are linked to each 'other. 'Database Objects - Initialization Dim oRs As DbConn, strQuery As String 'strXML will be used to store the entire XML document generated Dim strXML As String 'Generate the graph element strXML = "" 'Iterate through each factory strQuery = "select * from Factory_Master" oRs = New DbConn(strQuery) While oRs.ReadData.Read() 'Now create second recordset to get details for this factory strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" & oRs.ReadData("FactoryId").ToString() Dim oRs2 As New DbConn(strQuery) oRs2.ReadData.Read() 'Generate strXML = strXML & "" 'Close recordset oRs2.ReadData.Close() End While oRs.ReadData.Close() 'Finally, close element strXML = strXML & "" 'Create the chart - Pie 3D Chart with data from strXML Return FusionCharts.RenderChart("../FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", "650", "450", False, False) End Function End Class