classic asp
[classic asp] 페이징처리 속도개선
콩배
2019. 2. 13. 13:30
<%
Dim Page
Page = 1 '보여줄 페이지
Dim ListCnt, RecordCnt, PageCount
'총페이지 수를 위한 쿼리
Sql = "SELECT COUNT(*) " &_
"FROM tblBoard "
Set Rs = Server.CreateObject("adodb.recordset")
Rs.Open Sql, db, 1
RecordCnt = Rs.Fields(0)
Rs.Close
Set Rs = Nothing
ListCnt = 4 '한페이지의 리스트수
PageCount = -(Int(-(RecordCnt / ListCnt))) '총페이지수
'데이터 리스트업 쿼리
Sql = "SELECT rowNum, name, title, content, registDt " &_
"FROM ( " &_
"SELECT ROW_NUMBER() OVER(ORDER BY registDt DESC) AS rowNum " &_
", name, title, content, registDt " &_
"FROM tblBoard " &_
") AS SUB " &_
"WHERE rowNum >= " & (Page - 1) * ListCnt +1 & " AND rowNum <= " & Page * ListCnt & " " &_
"ORDER BY rowNum "
Set Rs = Server.CreateObject("adodb.recordset")
Rs.Open Sql, db, 1
Call Paging(Page, PageCount) '페이징 화면
Sub Paging(Page, PageCount)
Dim blockpage, i
blockpage = INT((Page - 1) / 10) * 10 + 1
'********** 이전 10 개 구문 시작 **********
If blockPage = 1 Then
Response.Write "<a><img src='../image/page_prev.png'></a>" '이전
Else
Response.Write"<a href='expert_column_default.asp?Page=" & blockPage-10 & "#page'><img src='../image/page_prev.png'></a> " '이전
End If
'********** 이전 10 개 구문 끝**********
i=1
Do Until i > 10 or blockpage > PageCount
If blockpage = INT(Page) Then
Response.Write "<a class='active'>" & blockpage & "</a> "
Else
Response.Write" <a href='expert_column_default.asp?Page=" & blockpage & "#page'>" & blockpage & "</a> "
End If
blockpage = blockpage+1
i = i + 1
Loop
'********** 다음 10 개 구문 시작**********
If blockpage > PageCount Then
Response.Write "<a><img src='../image/page_next.png'></a>" '이후
Else
Response.write" <a href='expert_column_default.asp?Page=" & blockPage & "#page'><img src='../image/page_next.png'></a>" '이후
End If
'********** 다음 10 개 구문 끝**********
End Sub
%>