泉武弘 泉武弘
泉武弘 公式サイト
| お気に入りに追加 | 知人に教える |  
泉武弘
泉武弘
" & vbCrLf For I = 0 To 1 - 1 %> <% ndate=dbopen("ndate") Title=dbopen("Title") Message=dbopen("Message") %>
更新履歴
 
<% '***************************************************************************** Dim iPageSize 'How big our pages are Dim iPageCount 'The number of pages we get back Dim iPageCurrent 'The page we want to show Dim strOrderBy 'A fake parameter used to illustrate passing them Dim SQL 'SQL command to execute Dim dbconect 'The ADODB connection object Dim dbopen 'The ADODB recordset object Dim iRecordsShown 'Loop controller for displaying just iPageSize records Dim I 'Standard looping var ' Get parameters iPageSize = 10 ' You could easily allow users to change this ' Retrieve page to show or default to 1 If Request.QueryString("page") = "" Then iPageCurrent = 1 Else iPageCurrent = CInt(Request.QueryString("page")) End If ' Make sure the input is one of our fields. strOrderBy = LCase(Request.QueryString("ndate")) Select Case strOrderBy Case "strOrderBy" strOrderBy = strOrderBy Case Else strOrderBy = "ndate" End Select '-------------------------------------------------------------------// Set dbconect = Server.CreateObject("ADODB.Connection") dbconect.Open "DSN=izumi; User ID=izumi; Password=izumi" Set dbopen = Server.CreateObject("ADODB.Recordset") SQL = "SELECT * FROM testtable ORDER BY ndate DESC" dbopen.PageSize = iPageSize ' You can change other settings as with any RS 'objPagingRS.CursorLocation = adUseClient dbopen.CacheSize = iPageSize dbopen.Open SQL, dbconect, adOpenStatic, adLockReadOnly, adCmdText ' Get the count of the pages using the given page size iPageCount = dbopen.PageCount ' If the request page falls outside the acceptable range, ' give them the closest match (1 or max) If iPageCurrent > iPageCount Then iPageCurrent = iPageCount If iPageCurrent < 1 Then iPageCurrent = 1 ' Check page count to prevent bombing when zero results are returned! If iPageCount = 0 Then Response.Write "レコードがありません。" Else ' Move to the selected page dbopen.AbsolutePage = iPageCurrent ' Start output with a page x of n line %> ページ(<%= iPageCurrent %>/ <%= iPageCount %>)
<%'----------SHOW PRE-NEXT PAGES-----------------------/// ' Show "previous" and "next" page links which pass the page to view ' and any parameters needed to rebuild the query. If iPageCurrent > 1 Then %> [<<] <% End If ' Show page numbers: For I = 1 To iPageCount If I = iPageCurrent Then %> <%= I %> <% Else %> <%= I %> <% End If Next 'I If iPageCurrent < iPageCount Then %> [>>] <% End If '----------END OF SHOWING PRE-NEXT PAGES-----------------------------/// %>
 
<% ' Loop through our records and ouput 1 row per record iRecordsShown = 0 Do While iRecordsShown < iPageSize And Not dbopen.EOF ' Response.Write vbTab & "
<% Next ' Increment the number of records we've shown iRecordsShown = iRecordsShown + 1 ' move to the next record dbopen.MoveNext Loop End If ' Close DB objects and free variables dbopen.Close set dbopen = Nothing dbconect.Close set dbconect = Nothing %>
<%= ndate %>
<%= Title %>
<%= Message %>
 
<%'----------SHOW PRE-NEXT PAGES-----------------------/// ' Show "previous" and "next" page links which pass the page to view ' and any parameters needed to rebuild the query. If iPageCurrent > 1 Then %> [<<] <% End If ' Show page numbers: For I = 1 To iPageCount If I = iPageCurrent Then %> <%= I %> <% Else %> <%= I %> <% End If Next 'I If iPageCurrent < iPageCount Then %> [>>] <% End If '----------END OF SHOWING PRE-NEXT PAGES-----------------------------/// %>
ページ(<%= iPageCurrent %>/ <%= iPageCount %>)
 
Copyright 2004 Izumi Takehiro All Rights Reserved.