程序代碼
以下為引用的內容
<%
Class dbClass
private conn
private Sub Class_Initialize()
dim dbPath
dim dbUser
dim dbPass
dim connstr
dbPath = "/testasp/data/data
dbUser = "admin"
dbPass = "
connstr = "Provider=Microsoft
";User ID=" & dbUser & ";Password=;Jet OLEDB:Database Password=" & dbPass
on error resume next
set conn=server
conn
errMsg "連接數據庫"
End Sub
Private Sub Class_terminate()
conn
set conn=nothing
End Sub
Public Property Let sqlStr(Byval Values)
strsql=Values
End Property
public property let tbName(Byval Values)
vTbName=Values
end property
public property let pKey(ByVal Values)
vPKey=Values
end property
public property let pgFields(ByVal Values)
vPgFields=Values
end property
public property let pgSize(ByVal Values)
vPgSize=Values
end property
public property let currPg(ByVal Values)
vCurrPg=Values
end property
public property let conditions(ByVal Values)
if Len(Values)>
vConditions=" where "&Values
else
vConditions=" where
end if
end property
public property let orderBy(ByVal Values)
if Len(Values)>
vOrderBy=" order by "&Values
else
vOrderBy=Values
end if
end property
public property get vRsCount()
if vCurrPg=
sqlc="select count("&vPKey&") as Idcount from "&vTbName&" "&vConditions
set rsc=server
rsc
RsNum=rsc("IdCount")
rsc
set rsc=nothing
if RsNum>
response
vRsCount=RsNum
else
vRsCount=
end if
else
vRsCount=request
end if
end property
public property get vPgCount()
iRsCount
if iRsCount
vPgCount=int(iRsCount
else
vPgCount=int(iRsCount
end if
end property
Public Function rsDB()
on error resume next
Set rsDB=conn
errMsg "查詢數據庫"
End Function
public Function upDB()
on error resume next
conn
errMsg "編輯數據庫記錄"
end Function
public function pageRs()
on error resume next
dim startRs
startRs=(vCurrPg
if startRs=
strsql="select top "&vPgSize&" "&vPgFields&" from "&vTbName&" "&vConditions&" "&vOrderBy
else
strsql="select top "&vPgSize&" "&vPgFields&" from "&vTbName&" "&vConditions&" and "&vPKey&" not "
strsql=strsql&"in (select top "&startRs&" "&vPKey&" from "&vTbName&" "&vConditions&" "&vOrderBy
strsql=strsql&") "&vOrderBy
end if
set pageRs=server
pageRs
errMsg "記錄分頁"
end function
public function sqlPage()
on error resume next
Set sqlPage=server
Set Cm=Server
Cm
Cm
Cm
Cm
Cm
Cm
Cm
Cm
Cm
Cm
Cm
Cm
sqlPage
sqlPage
sqlPage
errMsg "記錄分頁"
end function
Public Function cRs(ByVal ObjRs)
ObjRs
Set ObjRs = Nothing
End Function
public function pageNav()
iRsCount=vRsCount()
mypage=vCurrPg
PgCount=vPgCount()
prePage=mypage
if prePage<
prePage=
end if
nextPage=mypage+
if nextPage>PgCount then
nextPage=PgCount
end if
pagestr="<div id=""fy""><span id=""rpc"">總共有"&iRsCount&"條記錄 "&mypage&"/"&PgCount&"</span>"
pagestr=pagestr&"<a class=
if (mypage
firstPage=mypage
elseif int((mypage
firstPage=
else
firstPage=int((mypage
end if
endPage=firstPage+
astr=""
for i=firstPage to endPage
astr=astr&"<a ?currpage="&i&"
if Cstr(mypage)=Cstr(i) then
astr=astr&" id=
end if
astr=astr&">"&i&"</a>"
if i>PgCount
next
astr=astr&"<a ?currpage="&nextPage&"
pagestr=pagestr&astr
pageNav=pagestr
end function
Function showTb(ByVal TbTil)
set rsTb=pageRs()
tbRs= rsTb
cRs(rsTb)
iTblRow=Ubound(tbRs
iTblCol=Ubound(TbTil)
tbStr="<table border=
for r
tr
next
tr
for ri=
for ci=
td=td&"<td width=
next
tr=tr&"<tr>"&td&"</tr>"
td=null
next
TbTil=null
tbRs=null
response
tbStr=null
tr
tr=null
End Function
Public Sub prnSql()
response
End Sub
Private Function errMsg(errMsg)
If Err
response
Err
Response
Response
End If
End Function
End Class
%>
From:http://tw.wingwit.com/Article/program/net/201311/14424.html