ASP using stored procedures to implement data paging

Source: Internet
Author: User

First, create a 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

Else
%>



Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.