/ ***** Listening to the previous colleagues said that the paging on the ASP page is too slow (if there is more data),
I thought about such a stupid approach. Some places have to consider -, such as SELECT TOP 22 * from cat_list
WHERE T_ID NOT IN (SELECT T_ID from #change) Is there an efficient problem; data cannot be repeated, etc.
But flexibility is very good. I hope that everyone will give it to help correct; thank you chair3 help --- This stored procedure can also join several variables, casually change:) ***** /
Create Proc Page
@PAGENUM INT
AS
SET NOCOUNT ON / * ----- This sentence is very important :)), otherwise it will only recognize insert #change ... this data set :)) * /
Declare @SQL NVARCHAR (500) - Declaration Dynamic SQL Execution Statement
Declare @PageCount Int - Current page number
- Total number of records to get the current database
Declare @Row_num Int
Begin
SELECT @ row_num = count (*) from cat_list
- Create a temporary table as data filtering
Create Table #change (T_ID INT)
- Judging the current number of pages
IF @Row_num> 6 - Big than the page display record number, page
Begin
Set @ row_num = @ Pagenum * 6
IF @ row_num = 6
SELECT TOP 6 * from cat_list
Else
Begin
Set @row_num = (@ PAGENUM-1) * 6
Set @ PageCount = @ row_num
Set @ SQL = N'Insert #Change (T_ID) SELECT TOP ' CAST (@PageCount As Char (100)) ' T_ID from cat_list where t_id not in (SELECT T_ID from #change) '
EXEC SP_EXECUTESQL @SQL
SELECT TOP 6 * from cat_list where t_id not in (SELECT T_ID from #change)
end
end
Else - Reality All data
SELECT * from cat_list
end
Go
The client calls:
<% DIM T_COM
Dim T_RS'Declare DataManage Recordset
Dim Parameters
Set t_com = server.createObject ("adoDb.command")
T_com.activeConnection = conn
T_com.commandtext = "Page"
T_com.commandType = AdcmdStoredProc
'T_com.prepared = true
Set parameters = t_com.createParameter ("@ Pagenum", Adinteger, Adparaminput) t_com.parameters.Append parameters
DIM Page
Page = Request.QueryString ("Page")
IF page = "" "
Page = 1
END IF
T_com ("@ Pagenum") = Page
Set T_RS = T_com.execute
Do While Not T_RS.eof
Response.write T_RS ("c_name")
T_RS.MOVENEXT
loop
%>