<%
' ----------------------------------------------------------------
' The following script is a sample script designed to demonstrate
' a method for creating real-time dynamic pie charts from data
' held within databases.
'
' This sample connects to a database via DSN and reads data from
' a table "SalesLine". It then formats the data for use by the
' Line Graph Applet.
'
' You may freely copy and modify this script to suite your own
' requirements.
'
' ----------------------------------------------------------------

<%
' -- Make Database Connection
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=myCONNECTION.dsn"
objConn.Open
%>

<%
' -- Perform SQL query for Product X
DIM mySQL1, objRS1
mySQL1 = "Select Value from SalesLine where Year=2004 and Product='X' ORDER BY Month"
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open mySQL1, objConn1

' -- Perform SQL query for Product Y
DIM mySQL2, objRS2
mySQL2 = "Select Value from SalesLine where Year=2004 and Product='Y' ORDER BY Month"
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open mySQL2, objConn2
%>

<!-- Chart Data -->
<%
DIM iDataCount

' Construct data tags for series 1
iDataCount = 0
DO WHILE NOT objRS1.EOF
    iDataCount = iDataCount + 1
%>

data<%=idataCount%>series1:  <%=objRS1("Value")%>

<%
    objRS1.MoveNext
Loop
objRS1.Close
%>

<%
' Construct data Param tags for series 2
iDataCount = 0
DO WHILE NOT objRS2.EOF
    iDataCount = iDataCount + 1
%>

data<%=idataCount%>series2:  <%=objRS2("Value")%>

<%
    objRS2.MoveNext
Loop
objRS2.Close
%>

<%
' Close Database Connection
objConn.Close()
Set objConn = Nothing
%>