沧州师范学院计算机系毕业论文
图13
4、发表留言浏览效果图,如图14。
图14
二、关键代码设计
(一) 页面相同基本信息代码页面 include.asp
16
沧州师范学院计算机系毕业论文
<%
set oRs=server.createobject(\sSql=\oRs.Open sSql,Conn,1,1 If Not oRs.Eof Then
W_ID=oRs(\
W_WebsiteAppe=oRs(\W_SuppExpl=oRs(\W_WebSiteName=oRs(\W_WebSiteUrl=oRs(\W_StatMastName=oRs(\W_StatMastEmail=oRs(\W_StatMastQQ=oRs(\
W_WebSiteKeyword=oRs(\W_WebSiteIntr=oRs(\
W_WebSiteCopyInfo=oRs(\
End If oRs.Close
If W_WebsiteAppe=\
Response.Write \Response.Write W_SuppExpl
Response.Write \Response.End
cellspacing='0'>\
End If
Dim WebTitle,WebName
WebName=W_WebSiteName&\WebTitle=\%>
(二)数据库连接代码页面 conn.asp <%
Function SafeRequest(ParaName,ParaType) Dim ParaValue
ParaValue=Request(ParaName)
17
沧州师范学院计算机系毕业论文
If ParaType=1 then
If not isNumeric(ParaValue) then
Response.write \参数\必须为数字型,请正确操作!\Response.end End if Else
ParaValue=replace(ParaValue,\End if
SafeRequest=ParaValue End function
Function FormatSQL(strChar)
if IsNull(strChar) Or IsEmpty(strChar) then FormatSQL=\else
FormatSQL=replace(strChar,\ FormatSQL=replace(FormatSQL,\\FormatSQL=replace(FormatSQL,\?\FormatSQL=replace(FormatSQL,\(\FormatSQL=replace(FormatSQL,\)\FormatSQL=replace(FormatSQL,\﹤\FormatSQL=replace(FormatSQL,\﹥\FormatSQL=replace(FormatSQL,\。\FormatSQL=replace(FormatSQL,\;\FormatSQL=replace(FormatSQL,\=\FormatSQL=replace(FormatSQL,\%\FormatSQL=replace(FormatSQL,\※\end if End Function dim conn dim connstr
db=\
connstr = \+ server.mappath(db) + \Access Driver (*.mdb)};\
set conn=server.createobject(\
18
沧州师范学院计算机系毕业论文
if err.number<>0 then %>
(三)分页功能模块代码 <%
if not rs.eof then
rs.MoveFirst '注意放到前面来,否则到任何页总是在第一个记录上 end if
rs.pagesize=MaxPerPage '设置每页最多显示多少条记录 If trim(Request(\ '如果请求的页次不为空
CurrentPage= CLng(request(\ 'clng是转换成长整型数据类型,并赋值到当If CurrentPage> rs.PageCount then '如果当前页次大于总页数,则将最大页次赋值
CurrentPage = rs.PageCount
前页次上 到当前页次上
End If
CurrentPage= 1 '一切条件不成立,将当前页设为第一页 err.clear set conn=nothing
response.write \数据库连接出错!\Response.End conn.open connstr if err then
err.clear set conn=nothing
response.write \数据库连接出错!\Response.End
else
end if
end if
Else End If
totalPut=rs.recordcount '将总记录赋值于TOTALPUT
if CurrentPage<>1 then '如果当前页数不等于第一页
19
沧州师范学院计算机系毕业论文
%>
if (currentPage-1)*MaxPerPage rs.move(currentPage-1)*MaxPerPage '相对当前记录数向后移动 dim bookmark '定义书签变量 bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上 的记录数小于总记录的话 end if end if dim n,k if (totalPut mod MaxPerPage)=0 then '总记录数与每页最大记录数求余的结果为 n= totalPut \\ MaxPerPage n= totalPut \\ MaxPerPage + 1 零时,则N返回整数页次,否则再加一. else end if (四)图片显示功能模块代码 sql=\else sql=\end if set rsnews=server.createobject(\rsnews.open sql,conn,1,1 if rsnews.eof then Response.Write \end if IF Not rsnews.eof Then proCount=rsnews.recordcount rsnews.PageSize=24 '定义显示数目 if not IsEmpty(Request(\ ToPage=CInt(Request(\ 20