home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Grafica / 3dpie / TemplateScripts / ASP / PieAppletDB.asp next >
Encoding:
Text File  |  2004-07-02  |  2.9 KB  |  104 lines

  1. <html>
  2. <head>
  3. <title>3D Pie Chart</title>
  4. </head>
  5. <body>
  6.  
  7. <!-- ---------------------------------------------------------------- -->
  8. <!-- The following script is a sample script designed to demonstrate  -->
  9. <!-- a method for creating real-time dynamic pie charts from data     -->
  10. <!-- held within databases.                                           -->
  11. <!--                                                                  -->
  12. <!-- This sample connects to a database (via DSN) and reads data from -->
  13. <!-- a table "SalesBar". It then constructs the html page dynamically -->
  14. <!-- inserting the values from the result set into the parameters of  -->
  15. <!-- the Pie Chart Applet.                                            -->
  16. <!--                                                                  -->
  17. <!-- You may freely copy and modify this script to suite your own     -->
  18. <!-- requirements.                                                    -->
  19. <!--                                                                  -->
  20. <!-- ---------------------------------------------------------------- -->
  21.  
  22. <%
  23. ' -- Make Database Connection
  24. DIM objConn
  25. Set objConn = Server.CreateObject("ADODB.Connection")
  26. objConn.ConnectionString = "DSN=myCONNECTION.dsn"
  27. objConn.Open
  28. %>
  29.  
  30.  
  31. <%
  32. ' -- Perform SQL query for Product X
  33. DIM mySQL1, objRS1
  34. mySQL1 = "Select Value from SalesBar where Year=2004 and Product='X' ORDER BY Month"
  35. Set objRS1 = Server.CreateObject("ADODB.Recordset")
  36. objRS1.Open mySQL1, objConn
  37.  
  38.  
  39. ' -- Perform SQL query for Product Y
  40. DIM mySQL2, objRS2
  41. mySQL2 = "Select Value from SalesBar where Year=2004 and Product='Y' ORDER BY Month"
  42. Set objRS2 = Server.CreateObject("ADODB.Recordset")
  43. objRS2.Open mySQL2, objConn
  44. %>
  45.  
  46.  
  47.  
  48. <applet code='PiechartApplet.class' archive='Piechart.jar' width='500' height='420'>
  49.  
  50.   <!-- Start Up Parameters -->
  51.   <PARAM name='LOADINGMESSAGE' value='Pie Chart Loading - Please Wait.'>     <!-- Message to be displayed on Startup -->
  52.   <PARAM name='STEXTCOLOR' value='0,0,100'>                                  <!-- Message Text Color-->
  53.   <PARAM name='STARTUPCOLOR' value='255,255,255'>                            <!-- Applet Background color -->
  54.  
  55.   <!-- Property file -->
  56.   <PARAM name='chartproperties' value='piepropsdb.txt'>
  57.  
  58.   <!-- Chart Data -->
  59.  
  60. <%
  61. DIM iDataCount
  62.  
  63. ' Construct data Param tags for series 1
  64. iDataCount = 0
  65. DO WHILE NOT objRS1.EOF
  66.     iDataCount = iDataCount + 1
  67. %>
  68.  
  69. <param name='data<%=iDataCount%>series1' value='<%=objRS1("Value")%>'>
  70.  
  71. <%
  72.     objRS1.MoveNext
  73. Loop
  74. objRS1.Close
  75. %>
  76.  
  77.  
  78. <%
  79. ' Construct data Param tags for series 2
  80. iDataCount = 0
  81. DO WHILE NOT objRS2.EOF
  82.     iDataCount = iDataCount + 1
  83. %>
  84.  
  85. <param name='data<%=iDataCount%>series2' value='<%=objRS2("Value")%>'>
  86.  
  87. <%
  88.     objRS2.MoveNext
  89. Loop
  90. objRS2.Close
  91. %>
  92.  
  93. </applet>
  94.  
  95.  
  96. <%
  97. ' Close Database Connection
  98. objConn.Close()
  99. Set objConn = Nothing
  100. %>
  101.  
  102. </body>
  103. </html>
  104.