国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP實例:利用緩存提高數據顯示效率_ASP教程

2024-05-04 11:03:33
字體:
來源:轉載
供稿:網友

推薦:Windows 2003 安裝設置iis
安裝篇2003默認安裝不帶IIS的,要安裝,請點擊開始->管理工具->配置您的服務器向導然后一步步的下一步。到了列表選擇項目的時候。從列表中選擇應用服務器(IIS,ASP.NET)

實例演示:先建立一個簡單的數據庫,寫個function讀取一下,寫入一個dim變量temp中:

ASP代碼

以下為引用的內容:
<%
Function DisplayRecords()
Dim sql, conn, rs
sql = "SELECT id, [szd_f], [szd_t] FROM admin"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("db.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1, 3
If Not rs.EOF Then
Dim temp
temp = "<table width=""90%"" align=""center"""
temp = temp & " border=""1"" bordercolor=""silver"""
temp = temp & " cellspacing=""2"" cellpadding=""0"">"
temp = temp & "<tr bgcolor=""#CCDDEE""><td width=""5%"""
temp = temp & ">ID</td><td>操作</td>"
temp = temp & "<td>數值</td></tr>"
While Not rs.EOF
temp = temp & "<tr><td bgcolor=""#CCDDEE"">"
temp = temp & rs("ID") & "</td><td>" & rs("szd_f")
temp = temp & "</td><td>" & rs("szd_t")
temp = temp & "</td></tr>"
rs.MoveNext
Wend
temp = temp & "</table>"
DisplayRecords = temp
Else
DisplayRecords = "Data Not Available."
End If
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End Function
'寫入緩存
Function DisplayCachedRecords(Secs)
Dim retVal, datVal, temp1
retVal = Application("cache_demo")
datVal = Application("cache_demo_date")
If datVal = "" Then
datVal = DateAdd("s",Secs,Now)
End If
temp1 = DateDiff("s", Now, datVal)
If temp1 > 0 And retVal <> "" Then
DisplayCachedRecords = retVal
' Debugging Code :
Response.Write "<b><font color=""green"">利用緩存讀取數據"
Response.Write " ... (" & temp1 & " 秒剩余)</font></b>"
Response.Write "<br><br>"
Else
Dim temp2
' Change DisplayRecords() to the function whose
' value you want to cache
temp2 = DisplayRecords()
Application.Lock
Application("cache_demo") = temp2
Application("cache_demo_date") = DateAdd("s",Secs,Now)
Application.UnLock
DisplayCachedRecords = temp2
' Debugging Code :
Response.Write "<b><font color=""red"">刷新緩存顯示 ..."
Response.Write "</font></b><br><br>"
End If
End Function
%>
<!--
Response.Write DisplayRecords()
-->
<html>
<head>
<title>利用緩存從數據庫---讀取數據</title>
<style>
body, p, td { font-family:Sans-Serif; font-size:8pt; }
td { padding-left: 5; }
</style>
</head>
<body>
<%
Dim t1, t2
t1 = Timer
Response.Write DisplayCachedRecords(20)
t2 = Timer
%>
<p align="center">
停留時間: <%= Left((CDbl((t2 - t1) * 1000.0)), 5) %> ms
</p>
</body>
</html>

分享:ASP基礎教程之ASP AdRotator 組件的使用
ASP AdRotator 組件每當用戶進入網站或刷新頁面時,ASP AdRotator組件就會創建一個AdRotator對象來顯示一幅不同的圖片。語法: 以下為引用的內容

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泾川县| 方山县| 洪洞县| 西乌| 阳泉市| 莱芜市| 化德县| 崇礼县| 平和县| 平山县| 西乌珠穆沁旗| 紫阳县| 荔浦县| 东方市| 抚顺县| 道孚县| 曲阳县| 惠来县| 日照市| 连江县| 康定县| 夏津县| 东山县| 红安县| 光泽县| 赤壁市| 小金县| 建德市| 威海市| 溧阳市| 嘉义县| 壶关县| 湄潭县| 汕头市| 伊春市| 浦江县| 都匀市| 哈巴河县| 略阳县| 陇川县| 东安县|