将数据库中的数据通过client控件显示,有源代码


从浏览器到数据库关系:
browser
mschart control
javascript (client-side)
asp (server-side vbscript)
ado
odbc
dbms

关键在于将 RS 内的内容赋给 client-side javascript.
source code:

1@ LANGUAGE="VBSCRIPT" 
 1   
 2Dim oConn   
 3Dim oRs   
 4Dim curDir   
 5Dim Index   
 6  
 7  
 8Dim sqlstring   
 9sqlstring = "select field from table"   
10  
11' Create ADO Connection Component to connect   
12' with sample database   
13  
14Set oConn = Server.CreateObject("ADODB.Connection")   
15oConn.Open "DSN=localserver;SERVER=(local);UID=sa;PWD=;DATABASE=pubs"   
16Set oRs = oConn.Execute(sqlstring)   
1<script language="vbscript">   
2  

Response.Write "<!--"

1Sub Window_onload()   
2Dim A   
3A = Array(```
4   
5Do while (Not oRs.eof) 
 1 =Int(oRs(0))
 2```,```
 3 oRs.MoveNext   
 4Loop   
 5
 6```0)   
 7  
 8  
 9MSChart1.ChartType = 1   
10MSChart1.ChartData = A   
11  
12End sub   
13  

Response.Write "-->"

1</script>
1   
2oRs.close   
3oConn.close   
 1<html>
 2<head>
 3<meta content="Microsoft Visual InterDev 1.0" name="GENERATOR"/>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<title>Document Title</title>
 6</head>
 7<body>
 8<!-- Insert HTML here -->
 9<object classid="CLSID:31291E80-728C-11CF-93D5-0020AF99504A" codebase="msChart.cab#version=5.0.37.14" height="268" id="MSChart1" width="356">
10</object>
11</body>
12</html>
Published At
Categories with 数据库类
comments powered by Disqus