-------------存储过程---------------------
CREATE procedure p_splitpage
@sql nvarchar(4000), --要执行的sql语句
@page int=1, --要显示的页码
@pageSize int, --每页的大小
@pageCount int=0 out, --总页数
@recordCount int=0 out --总记录数
as
set nocount on
declare @p1 int
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output
set @recordCount = @pageCount
select @pagecount=ceiling(1.0*@pagecount/@pagesize)
,@page=(@page-1)*@pagesize+1
exec sp_cursorfetch @p1,16,@page,@pagesize
exec sp_cursorclose @p1
GO
---------------------------得到执行的查询语句的存储过程-----------------
CREATE PROCEDURE dtalyjd_search (@search_name varchar(50)) AS
DECLARE @str varchar(4000)
if @search_name=''
begin
set @str='select * from 表名'
select @str sql
return
end
else
begin
set @str='select * from 表名 where
search_name like ''%'+@search_name+'%'''
select @str sql
return
end
GO
--------------------------ASP页面---------------------
<%
dim search_name
search_name=trim(request("search_name"))
set rs1=conn.execute("exec dtalyjd_search '"&search_name&"'")
sql=rs1("sql")
rs1.close
if request("page")="" or request("page")=0 or IsNumeric(request("page"))=false then
m_page=1
else
m_page=cint(request("page"))
end if
m_pagesize=14'每页的条数
set cmd = server.CreateObject("adodb.command")
cmd.ActiveConnection = conn
cmd.CommandType = 4
cmd.CommandText = "p_SplitPage"
cmd.Parameters.Append cmd.CreateParameter("@sql",8,1, 4000, sql)
cmd.Parameters.Append cmd.CreateParameter("@page",4,1, 4, m_page)
cmd.Parameters.Append cmd.CreateParameter("@pageSize",4,1, 4, m_pageSize)
cmd.Parameters.Append cmd.CreateParameter("@pageCount",4,2, 4, m_pageCount)
cmd.Parameters.Append cmd.CreateParameter("@recordCount",4,2, 4, m_recordCount)
set rs = cmd.Execute
set rs = rs.NextRecordSet
m_pageCount = cmd.Parameters("@pageCount").value
m_recordCount = cmd.Parameters("@recordCount").value
if m_pageCount = 0 then m_pageCount = 1
if m_page>m_pageCount then
response.Redirect("bureauser_result.asp?page="&m_pageCount&"&lxsuser_name="&lxsuser_name)
end if
set rs = cmd.Execute
%>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="47%" align="right">查询结果共 <font color="#FF0000">[8]</font>页 这是第 <font color="#FF0000">[5]</font> 页</td>
<td width="53%" align="right">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" align="right" ><img src="feedback_images/ll.gif" width="8" height="21"></td>
<td width="475" background="feedback_images/m.gif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%
if m_page<>1 then
%>
<td width="23%"><img src="images/first.gif" width="8" height="8"> <A HREF=<%=Myself%>?Page=1&search_name=<%=search_name%>>首页</A></td>
<td width="31%"><img src="images/pre.gif" width="8" height="8"> <A HREF=<%=Myself%>?Page=<%=(Page-1)%>&search_name=<%=search_name%>>上一页</a></td>
<%
end if
If m_page <> m_pageCount Then
%>
<td width="24%"><img src="images/lat.gif" width="8" height="8"><A HREF=<%=Myself%>?Page=<%=(m_Page+1)%>&search_name=<%=search_name%>>下一页</A></td>
<td width="22%"><img src="images/last.gif" width="8" height="8"><A HREF=<%=Myself%>?Page=<%=m_pageCount%>&search_name=<%=search_name%>>尾页</A></td>
<%end if%>
</tr><%end if%>
</table></td>
<td width="11"><img src="feedback_images/rr.gif" width="10" height="21"></td>
</tr>
</table>
</td>
</tr>
</table>
CREATE procedure p_splitpage
@sql nvarchar(4000), --要执行的sql语句
@page int=1, --要显示的页码
@pageSize int, --每页的大小
@pageCount int=0 out, --总页数
@recordCount int=0 out --总记录数
as
set nocount on
declare @p1 int
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output
set @recordCount = @pageCount
select @pagecount=ceiling(1.0*@pagecount/@pagesize)
,@page=(@page-1)*@pagesize+1
exec sp_cursorfetch @p1,16,@page,@pagesize
exec sp_cursorclose @p1
GO
---------------------------得到执行的查询语句的存储过程-----------------
CREATE PROCEDURE dtalyjd_search (@search_name varchar(50)) AS
DECLARE @str varchar(4000)
if @search_name=''
begin
set @str='select * from 表名'
select @str sql
return
end
else
begin
set @str='select * from 表名 where
search_name like ''%'+@search_name+'%'''
select @str sql
return
end
GO
--------------------------ASP页面---------------------
<%
dim search_name
search_name=trim(request("search_name"))
set rs1=conn.execute("exec dtalyjd_search '"&search_name&"'")
sql=rs1("sql")
rs1.close
if request("page")="" or request("page")=0 or IsNumeric(request("page"))=false then
m_page=1
else
m_page=cint(request("page"))
end if
m_pagesize=14'每页的条数
set cmd = server.CreateObject("adodb.command")
cmd.ActiveConnection = conn
cmd.CommandType = 4
cmd.CommandText = "p_SplitPage"
cmd.Parameters.Append cmd.CreateParameter("@sql",8,1, 4000, sql)
cmd.Parameters.Append cmd.CreateParameter("@page",4,1, 4, m_page)
cmd.Parameters.Append cmd.CreateParameter("@pageSize",4,1, 4, m_pageSize)
cmd.Parameters.Append cmd.CreateParameter("@pageCount",4,2, 4, m_pageCount)
cmd.Parameters.Append cmd.CreateParameter("@recordCount",4,2, 4, m_recordCount)
set rs = cmd.Execute
set rs = rs.NextRecordSet
m_pageCount = cmd.Parameters("@pageCount").value
m_recordCount = cmd.Parameters("@recordCount").value
if m_pageCount = 0 then m_pageCount = 1
if m_page>m_pageCount then
response.Redirect("bureauser_result.asp?page="&m_pageCount&"&lxsuser_name="&lxsuser_name)
end if
set rs = cmd.Execute
%>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="47%" align="right">查询结果共 <font color="#FF0000">[8]</font>页 这是第 <font color="#FF0000">[5]</font> 页</td>
<td width="53%" align="right">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" align="right" ><img src="feedback_images/ll.gif" width="8" height="21"></td>
<td width="475" background="feedback_images/m.gif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%
if m_page<>1 then
%>
<td width="23%"><img src="images/first.gif" width="8" height="8"> <A HREF=<%=Myself%>?Page=1&search_name=<%=search_name%>>首页</A></td>
<td width="31%"><img src="images/pre.gif" width="8" height="8"> <A HREF=<%=Myself%>?Page=<%=(Page-1)%>&search_name=<%=search_name%>>上一页</a></td>
<%
end if
If m_page <> m_pageCount Then
%>
<td width="24%"><img src="images/lat.gif" width="8" height="8"><A HREF=<%=Myself%>?Page=<%=(m_Page+1)%>&search_name=<%=search_name%>>下一页</A></td>
<td width="22%"><img src="images/last.gif" width="8" height="8"><A HREF=<%=Myself%>?Page=<%=m_pageCount%>&search_name=<%=search_name%>>尾页</A></td>
<%end if%>
</tr><%end if%>
</table></td>
<td width="11"><img src="feedback_images/rr.gif" width="10" height="21"></td>
</tr>
</table>
</td>
</tr>
</table>