如何将使用存储过程得到的结果集分页???

ddff2004 2005-07-20 01:09:50
将使用存储过程得到的结果集分页和将使用一般sql语句得到结果分页的方法一样吗?
...全文
191 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
白夜花寒 2005-07-22
  • 打赏
  • 举报
回复
<script language='vbscript'>
dim field_info,theexceptfield,tablename
function createsqlstr
dim str : str=""
str=str & "@num int" & "<br />"
str=str & "@page int" & "<br />"
for each thefieldname in field_info
str=str & "@" & field_info(thefieldname) & "<br />"
next
str=str & "@" & theexceptfield & "<br />"

str=str & "declare @thepage int" & "<br />"

str=str & "set @thepage=(@page-1) * @num" & "<br />"



str=str & "set @sql='select top '+cast(@num as nvarchar(30))+' * from " & tablename
i=1
for each thefieldname in field_info
if i=1 then str=str & " where "
str=str & field_info(thefieldname) & "='+cast(@" & field_info(thefieldname) & " as nvarchar(30))+' and "
i=i+1
next
str=str & theexceptfield & " not in(select top '+cast(@thepage as nvarchar(30))+'" & " " & theexceptfield
str=str & " from " & tablename & " where "
i=1
for each thefieldname in field_info
if i<>1 then str=str & " and "
str=str & field_info(thefieldname) & "='+cast(@" & field_info(thefieldname) & " as nvarchar(30))+'"
i=i+1
next
str=str & "order by " & theexceptfield &") order by " & theexceptfield & "'"
createsqlstr=str
end function


function setfieldnum
set thefieldname=document.getElementById("fieldname")
set thesetnum=document.getElementById("setnum")
thenum=thesetnum.value
if isnumeric(thenum) then
thenum=Cint(thenum)

str="请输入您所要查询的字段名:" & "<br />"
for i=0 to thenum-1
str=str & "字段" & i+1 & ":<input type='text' name='fieldnames' size='30' />" & "<br />"
next
str=str & "请输入您所用的标识字段名:" & "<input type='text' id='exceptfield' />" & "<br />"
str=str & "请输入表明:" & "<input type='text' id='tablenamed' />" & "<br />"
str=str & "<a href='vbscript:saveinfo()'>显示sql</a>"
thefieldname.innerHTML=str
end if
end function

function saveinfo()
set theshowsql=document.getElementById("showsql")
set thefieldnames=document.getElementsByName("fieldnames")
set the_exceptfield=document.getElementById("exceptfield")
set field_info=createobject("scripting.dictionary")
set thetablename=document.getElementById("tablenamed")
theexceptfield=the_exceptfield.value
tablename=thetablename.value
for i=0 to thefieldnames.length-1
thevalue=thefieldnames(i).value
field_info.add thevalue,thevalue
next
str=createsqlstr
theshowsql.innerhtml=str
end function
</script>
<html>
<head>
<base target="_self">
</head>
<body>
设定:<input type='text' id='setnum' size='2' />----<a href='vbscript:setfieldnum()'>确定</a>
<div id='fieldname'>
</div>
<div id='showsql'>
</div>
</body>
</html>
ddff2004 2005-07-21
  • 打赏
  • 举报
回复
有没有一个好一点的通用的分页的例子啊?
ddff2004 2005-07-20
  • 打赏
  • 举报
回复
希望能有一个详细一点的答案,谢谢。
ddff2004 2005-07-20
  • 打赏
  • 举报
回复
白夜花寒(远藤花已谢,白夜花未寒)
如果想用高效分页程序该怎么做啊?
白夜花寒 2005-07-20
  • 打赏
  • 举报
回复
如果你希望用rs去分页的话是一样的.....

8过你也可以用高效分页程序

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧