WWW对大量数据查询的一种实现
Rs.MoveFirst
Rs.Move (page-1)*Session(“PageSize “)
for i=1 to Session(“PageSize “)
Response.Write "<tr>"
for j=0 to rs.Fields.Count-1
Response.Write "<td>" & rs.Fields(j).Value & "</td>"
next
Response.Write "</tr>"
Rs.MoveNext
if Rs.EOF then
exit for
end if
next
Response.Write "</table></center>"
Response.Write "<p><center>"
代码通过对象Rs的方法Move将记录指向由page确定的那一页的第一条记录,然后用循环语句依次列出每条记录。为了定位在某一页,必须使用一参数将页码信息传给服务器,此处,使用带参数的超级链接来实现。具体代码如下:
if page<>1 then
Response.Write "<a href=’onepage.asp?page=1’>第一页</a> "
Response.Write"<a href=’onepage.asp?page="&(page-1)&"’>上一页</a>"
end if
if page<>Session(“PageCount”) then
Response.Write "<a href=’onepage.asp?page=" & (page+1) & "’>下一页</a>"
Response.Write "<a href=’onepage.asp?page=" & Session(“PageCount”) & "’>最后一页</a>"
end if
Response.Write "</center></p>"
如果当前页是第一页,则仅显示“下一页”、“最后一页”,若当前页是最后一页,则仅显示“上一页”、“第一页”,除此之外,上述四个选项均显示。
4.结束语
文本文件onepage.asp存放于服务器上,这种方法与一次传输所有查询结果相比,优点是很明显的。程序实现了定位任一页的功能,更具有灵活性,连接时间也大大降低。因此,对于其他大容量数据库的连接查询操作,具有一定的借鉴意义。
参考文献:
(1) Piroz Mohseni著,Web数据库开发人员指南. 机械工业出版社.
(2) Leonid Braginski,Matthew Powell著,Microsoft Internet Information Server 4.0 使用大全. 人民邮电出版社.
(3) 沈文智,候勇等著,Microsoft IIS网页技术. 人民邮电出版社.
Inquire to Mass Data In World Wide Web
Abstract The enterprise designs a three tier architecture of client/server through integrating the technology of database access and www service. Then user may browse all kinds of enterprise’s information in Internet. Because of limits of bandwidth and transfers of mass data, the link of network usually breaks. This paper discusses the technologies of database access, and analyzes these technologies. By the demand of XinHua BookStore Publishing Group’s website, ASP paging technology is used to transmit mass data.
Keyword Activex Server Pages, ADO, Three Tier Architecture, Client/Server, Paging