日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

ASP快速開發(fā)方法之數(shù)據(jù)操作(2)_ASP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:ASP實例:即時顯示當前頁面瀏覽人數(shù)
ASP實現(xiàn)即時顯示當前頁面瀏覽人數(shù) online.asp文件 以下為引用的內(nèi)容: <!--#include file="dbconn.asp" --> <% onlineTimeout=10

那我再改進下:

把conn.asp文件改成:

以下為引用的內(nèi)容:
<%
Dim Conn
Dim Rs
Sub CloseDatabase
Conn.close
Set Conn = Nothing
End Sub
Sub OpenDatabase
Dim StrServer,StrUid,StrSaPwd,StrDbName
StrServer="192.168.1.1" '數(shù)據(jù)庫服務器名
StrUid="sa" '您的登錄帳號
StrSaPwd="" '您的登錄密碼
StrDbName="cnbruce.mdb" '您的數(shù)據(jù)庫名稱
Set Conn = Server.CreateObject("ADODB.Connection")
'用于連接ACCESS
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(StrDbName)
'用于連接MSSQL
'Conn.ConnectionString = "Driver={sql server};driver={SQL server};server="&StrServer&";uid="&StrUid&";pwd="&StrSaPwd&";database=
"&StrDbName
set rs=server.CreateObject("ADODB.RecordSet")
conn.open
if Err Then
err.Clear
Set Conn = Nothing
GBL_CHK_TempStr = GBL_CHK_TempStr & "數(shù)據(jù)庫連接錯誤!"
Response.Write GBL_CHK_TempStr
Response.End
End If
End Sub
%>

現(xiàn)在我們的showit.asp可以這樣寫:

showit.asp

以下為引用的內(nèi)容:
<!--#include file="conn.asp" -->
<%
sql = "Select * from cnarticle"
opendatabase
rs.Open sql,conn,1,1
If not Rs.eof then
Do Until rs.EOF
response.write("文章標題是:"& rs("cn_title"))
response.write("<br>文章作者是:"& rs("cn_author"))
response.write("<br>文章加入時間是:"& rs("cn_time"))
response.write("<br>文章內(nèi)容是:"& rs("cn_content"))
response.write("<hr>")
rs.MoveNext
Loop
else
response.write ("暫時還沒有文章")
end if
Closedatabase
%>

嗯,我們又少寫了一些東西,這樣是最簡單的嗎?當然不是!還可以更簡單。
使用GetRows把查詢出來的數(shù)據(jù)傳給一個變量,使用ubound方法取得數(shù)據(jù)記錄條數(shù)。
不明白?沒關(guān)系,讓我們繼續(xù)往下看:

再建個文件:sql.asp

sql.asp

以下為引用的內(nèi)容:
<%
Class DataTable
public Function SelectData(sql)
If sql<>"" then
opendatabase
Rs.open sql,conn,1,1
If not Rs.eof then
Thedata=Rs.GetRows(-1)
Closedatabase
Else
Closedatabase
End If
End If
SelectData=Thedata
End Function
End Class
%>

嗯,復制它就可以了,現(xiàn)在我們的showit.asp可以簡單地這樣寫:

showit.asp

以下為引用的內(nèi)容:
<!--#include file="conn.asp" -->
<!--#include file="sql.asp" -->
<%
sql = "Select * from cnarticle"
set loadData=new DataTable
Thedata=loadData.SelectData(sql)
If isarray(Thedata) then
Num=ubound(Thedata,2)
for i=0 to Num
response.write("文章標題是:"& Thedata(1,i))
response.write("<br>文章作者是:"& Thedata(2,i))
response.write("<br>文章加入時間是:"& Thedata(3,i))
response.write("<br>文章內(nèi)容是:"& Thedata(4,i))
response.write("<hr>")
next
else
response.write("暫時還沒有文章")
End If
%>

分享:ASP教程:解決ASP腳本運行超時的方法
最近在學習服務器知識。有時候遇到asp腳本運行超時的錯誤,真是麻煩。找了相關(guān)資料,其中有一些解決方法。 IIS默認的腳本超時時間是90秒 這樣的話如果你是上傳軟件或者傳送數(shù)據(jù)大于90秒的時

來源:模板無憂//所屬分類:ASP教程/更新時間:2008-08-22
相關(guān)ASP教程