Stored Procedures | pagination | Data first, CREATE TABLE Tiku_koushi
if exists (SELECT * from dbo.sysobjects WHERE id =
OBJECT_ID (N ' [dbo].[ Tiku_koushi] and ObjectProperty
(ID, N ' isusertable ') = 1)
drop table [dbo]. [Tiku_koushi]
Go
CREATE TABLE [dbo]. [Tiku_koushi] (
[ID] [int] IDENTITY (1, 1) not NULL,
[Title] [varchar] (COLLATE)
Chinese_prc_ci_as NULL,
[LIST2_ID] [Char] (a) COLLATE
Chinese_prc_ci_as NULL
) on [PRIMARY]
Go
Second, stored procedure Sp_c
CREATE proc Sp_c
@tablename varchar (50),
@title varchar (250),
@list2_id varchar (50)
As
If @tablename = ' Tiku_koushi '
Select COUNT (*) from Tiku_koushi where title like '% ' + @title + '% ' and list2_id= @list2_id
Go
Third, stored procedure Sp_search_tiku
CREATE PROCEDURE Sp_search_tiku
@tablename varchar (50),
@title varchar (250),
@list2_id varchar (10),
@pagesize int,
@page int
As
If @tablename = ' Tiku_koushi '
Begin
DECLARE @ks int
DECLARE @str varchar (200)
Set @ks = @pagesize * (@page-1)
If not EXISTS (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Temp_table91] and OBJECTPROPERTY (ID, N ' isusertable ') = 1)
Begin
SELECT * into temp_table91 from Tiku_koushi where
Title like '% ' + @title + '% ' and list2_id= @list2_id order
by id DESC
SET ROWCOUNT @pagesize
Set @str = ' SELECT * from temp_table91 where ID
(select Top ' +str (@ks) + ' IDs from temp_table91 ') '
Execute (@str)
drop table Temp_table91
End
End
Go
Four, search_koushi.asp
<!--#include file= "conn.asp"-->
<%
Line=6
If Request ("page") = "" Then
Page=1
Else
Page=request ("page")
End If
If Page<1 Then
Page=1
End If
Title=trim (Request ("title"))
List2_id=trim (Request ("list2_id"))
Set Rs2=conn.execute ("Sp_c ' Tiku_koushi ', '" &title& "', '" &list2_id& "")
Pagecount=cint (rs2 (0) \line)
if (CInt (rs2 (0)) mod line) =0 then
Pagecount=pagecount
Else
Pagecount=pagecount+1
End If
If CInt (page) >=pagecount Then
Page=cint (PageCount)
End If
Str= ""
str=str& "page=" &page& "&title=" &title& "&list2_id=" &list2_id
Set Rs=conn.execute
("Sp_search_tiku ' Tiku_koushi ', '" &title& ", '" &list2_id& "', '" &line& ", '", "&cint page) & "'")
If Rs.eof Then
Response.Write "No Record"
Else
%>
<style type= "Text/css" >
td{font-size:12px;}
A{text-decoration:none;}
</style>
<script language= "JavaScript" >
</script>
<body>
<table width= "518" border= "1" bordercolorlight= "000000"
bordercolordark= "#ffffff"
align= "center" cellpadding= "0" cellspacing= "0" >
<!--dwlayouttable-->
<tr bgcolor= #dfdfdf >
<TD width= "454" align= "center" height=24 valign= "Middle" > Questions </td>
<TD width= "align=" "Center" valign= "Middle" > Delete </td>
</tr>
<% Do until rs.eof%>
<tr height=22>
<TD valign= "Middle" > <a href=void (0) "
ID ")%>&page=<%=page%>&title=<%=title%>&list2_id=<%=list2_id%> ', ', ' width=518
height=160 left=100 ') >
<%=rs ("title")%></a></td>
<TD align= "center" valign= "Middle" > Delete </td>
</tr>
<%
Rs.movenext
Loop
%>
<tr align= "left" valign= "Middle" bgcolor= "Efeff6"
Height=22>
<TD colspan= "2" style= "PADDING-LEFT:6PX;" >
<a href= "Search_koushi.asp?page=<%=1%>&title=<%=title%>&list2_id=<%=list2_id%>" > Home </a> <a
href= "Search_koushi.asp?page=<%=page-1%>&title=<%=title%>&list2_id=<%=list2_id%>" > Prev </a> <a
href= "Search_koushi.asp?page=<%=page+1%>&title=<%=title%>&list2_id=<%=list2_id%>" > next page </a> <a
href= "Search_koushi.asp?page=<%=pagecount%>&title=<%=title%>&list2_id=<%=list2_id%>" > Last </a>
Total <%=pagecount%> page Current page: <%=page%>/<%=pagecount%> page
Total <%=rs2 (0)%> Records </td>
</tr>
</table>
</body>
<%
Rs2.close
Set rs2=nothing
Rs.close
Set rs=nothing
End If
%>