Asp implements data paging using stored procedures
Source: Internet
Author: User
I. 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] (250) COLLATE
Chinese_PRC_CI_AS NULL,
[List2_id] [char] (10) COLLATE
Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
II. Storage process 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
III. Storage 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 not in
(Select top '+ str (@ ks) + 'Id from temp_table91 )'
Execute (@ str)
Drop table temp_table91
End
End
GO
4. 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 rs21_conn.exe cute ("sp_c 'tiku _ koushi ','" & title & "','" & list2_id &"'")
Pagecount = CInt (rs2 (0) line)
If (CInt (rs2 (0) mod line) = 0 then
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service