<%@ Language="VBScript" %> <%Option Explicit%> <% '********************************************************************************* '** Date: 8/22/2002 '** Purpose: An online portfolio app to flip through a collection of images '********************************************************************************* ' Declare variables Dim intPageSize 'How big our pages are Dim intPageCount 'The number of pages we get back Dim intPageCurrent 'The page we want to show 'Dim intCategory 'A fake parameter used to illustrate passing them Dim strSQL 'SQL command to execute Dim objConn 'The ADODB connection object Dim objRS 'The ADODB recordset object Dim intRecordsShown 'Loop controller for displaying just iPageSize records Dim i 'Standard looping var Dim strConn 'Connection String 'category = 1 'this value can be passed via a form or querystring variable if need be 'set the number of records per page intPageSize = 1 ' Retrieve page to show or default to 1 If Request.QueryString("page") = "" Then intPageCurrent = 1 Else intPageCurrent = CInt(Request.QueryString("page")) End If strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/bruce.mdb") & ";Persist Security Info=False" 'create and open connection object Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open strConn ' Create recordset and set the page size Set objRS = Server.CreateObject("ADODB.Recordset") objRS.PageSize = intPageSize 'sql to pull info from DB strSQL = "SELECT file, name, sub FROM photos" ' Open RS objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText ' Get the count of the pages using the given page size intPageCount = objRS.PageCount ' If the request page falls outside the acceptable range, ' give them the closest match (1 or max) If intPageCurrent > intPageCount Then intPageCurrent = intPageCount If intPageCurrent < 1 Then intPageCurrent = 1 objRS.AbsolutePage = intPageCurrent %> Bruce Madden

<% ' Loop through our records and ouput 1 row per record intRecordsShown = 0 Do While intRecordsShown < intPageSize And Not objRS.EOF With Response .Write "" .Write "" .Write "" .Write "" .Write "" .Write "
" '.Write "

" & objRS("name").Value & "
" '.Write "" & objRS("sub").Value & "

" .Write "

" .Write "" End With ' Increment the number of records we've shown intRecordsShown = intRecordsShown + 1 ' Can't forget to move to the next record! objRS.MoveNext Loop ' Close DB objects and free variables objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %>

<% If intPageCurrent > 1 Then Response.Write "<< " Response.Write "Previous" End If %>

<%If intPageCurrent < intPageCount Then Response.Write "Next" Response.Write " >>" End If %>

New Page 1

| Email Bruce | Bruce Madden Home |

All words and music Copyright 2002-2004 by Bruce Madden.
All applicable laws apply.

Design by Double T Media