asp中使用set rs=conn.execute(sql)这一语句,,得到的rs.recordcount值只能是-1麼?

来源:百度知道 编辑:UC知道 时间:2024/07/04 10:32:59
在查询时,用到set rs=conn.exectue(sql),能显示查询结果,但是统计出来的查询结果却是-1,而且查询结果只能显示当前页?
怎样改进使之能够实现分页以及正确统计数据??

<!--#include file = "Include/include.asp"-->
<% dim rs2
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from [news] order by n_id desc",conn,1,1

page=1 ' 设置变量PAGE=1
rs2.PageSize = News_Front_Count '每页显示记录数
if Not IsEmpty(Request("Page")) then '如果PAGE已经初始化...
Page = CInt(Request("Page")) '接收PAGE并化为数字型赋给PAGE变量
End if
if Page > rs2.PageCount then '如果接收的页数大于总页数
rs2.AbsolutePage = rs2.PageCount '设置当前显示页等于最后页
end if
if Page <= 0 then '如果page小于等于0
Page = 1 '设置PAGE等于第一页
end if
rs2.AbsolutePage = Page '如果大于零,显示当前页等于接收的页数

%>
<table width="100%" height="470" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr >
<td valign="top">
<table widt