| Using with Database and scripts > ASP.NET, MS SQL Server and dataURL Method |
Here, we'll see how to use FusionCharts with ASP.NET using dataURL method. As we had earlier seen, the dataURL method requires two pages:
We'll first see the code for Data.aspx. Basically, here we request the year from querystring, retrieve the required data from database, convert it into XML and then write it to the output stream. |
| <%@ Import Namespace="System.Data"
%> <%@ Import Namespace="System.Data.SQLClient" %> <script runat="server"> Sub Page_Load(obj as Object, e as EventArgs) 'Container for the XML Data Dim strFCXMLData as String 'Request the year passed to this page Dim strYear as String strYear = Request.QueryString("Year") 'Establish a connection Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyCommand As SqlDataAdapter 'Get Top 5 Countries the database. MyConnection = New SqlConnection(ConfigurationSettings.AppSettings("appDSN")) MyCommand = New SqlDataAdapter("SELECT TOP 5 Country, SUM(ExtendedPrice) As Total, COUNT(DISTINCT OrderID) As orderNumber FROM Invoices WHERE YEAR(OrderDate)=" & strYear & " GROUP BY Country ORDER BY SUM(ExtendedPrice) DESC", MyConnection) 'Fill
the dataset |
| The code for Chart.aspx can be listed as under: |
<%@ Import Namespace="System.Data"
%> 'Fill the dataset Public Function formatFCUrl(strDataURL) as String |
| When you now view this chart, you'll get the following output: |
![]() |