home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Grafica / 3dpie / TemplateScripts / ASP / PieData.asp < prev   
Text File  |  2004-07-02  |  2KB  |  75 lines

  1. <%
  2. ' ----------------------------------------------------------------
  3. ' The following script is a sample script designed to demonstrate
  4. ' a method for creating real-time dynamic pie charts from data
  5. ' held within databases.
  6. '
  7. ' This sample connects to a database via DSN and reads data from
  8. ' a table "SalesBar". It then formats the data for use by the
  9. ' Pie Chart Applet.
  10. '
  11. ' You may freely copy and modify this script to suite your own
  12. ' requirements.
  13. '
  14. ' ----------------------------------------------------------------
  15.  
  16. <%
  17. ' -- Make Database Connection
  18. DIM objConn
  19. Set objConn = Server.CreateObject("ADODB.Connection")
  20. objConn.ConnectionString = "DSN=myCONNECTION.dsn"
  21. objConn.Open
  22. %>
  23.  
  24. <%
  25. ' -- Perform SQL query for Product X
  26. DIM mySQL1, objRS1
  27. mySQL1 = "Select Value from SalesBar where Year=2004 and Product='X' ORDER BY Month"
  28. Set objRS1 = Server.CreateObject("ADODB.Recordset")
  29. objRS1.Open mySQL1, objConn1
  30.  
  31. ' -- Perform SQL query for Product Y
  32. DIM mySQL2, objRS2
  33. mySQL2 = "Select Value from SalesBar where Year=2004 and Product='Y' ORDER BY Month"
  34. Set objRS2 = Server.CreateObject("ADODB.Recordset")
  35. objRS2.Open mySQL2, objConn2
  36. %>
  37.  
  38. <!-- Chart Data -->
  39. <%
  40. DIM iDataCount
  41.  
  42. ' Construct data tags for series 1
  43. iDataCount = 0
  44. DO WHILE NOT objRS1.EOF
  45.     iDataCount = iDataCount + 1
  46. %>
  47.  
  48. data<%=idataCount%>series1:  <%=objRS1("Value")%>
  49.  
  50. <%
  51.     objRS1.MoveNext
  52. Loop
  53. objRS1.Close
  54. %>
  55.  
  56. <%
  57. ' Construct data Param tags for series 2
  58. iDataCount = 0
  59. DO WHILE NOT objRS2.EOF
  60.     iDataCount = iDataCount + 1
  61. %>
  62.  
  63. data<%=idataCount%>series2:  <%=objRS2("Value")%>
  64.  
  65. <%
  66.     objRS2.MoveNext
  67. Loop
  68. objRS2.Close
  69. %>
  70.  
  71. <%
  72. ' Close Database Connection
  73. objConn.Close()
  74. Set objConn = Nothing
  75. %>