home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / MultiScrolling_VBScript.asp < prev    next >
Text File  |  1997-10-25  |  3KB  |  130 lines

  1. <% @LANGUAGE="VBSCRIPT"     %>
  2. <% Option Explicit            %>
  3.  
  4. <!--#include File="adovbs.inc"-->
  5.  
  6. <HTML>
  7.     <HEAD>
  8.         <TITLE>MultiScrolling Database Sample</TITLE>
  9.     </HEAD>
  10.  
  11.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  12.  
  13.  
  14.         <!-- Display Header -->
  15.  
  16.         <font size="4" face="Arial, Helvetica">
  17.         <b>MultiScrolling Database Sample</b></font><br>
  18.     
  19.         <hr size="1" color="#000000">
  20.  
  21.         Contacts within the Authors Database:<br><br>
  22.  
  23.         
  24.         <%
  25.             Dim oConn    
  26.             Dim oRs        
  27.             Dim curDir    
  28.             Dim Mv        
  29.             Dim PageNo    
  30.             Dim    j        
  31.             Dim i    
  32.             
  33.             
  34.             ' Map authors database to physical path
  35.             
  36.             curDir = Server.MapPath("\iissamples\sdk\asp\database\authors.mdb")
  37.  
  38.  
  39.             ' Create ADO Connection Component to connect with
  40.             ' sample database
  41.  
  42.             Set oConn = Server.CreateObject("ADODB.Connection")
  43.             oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
  44.  
  45.             
  46.             ' Create ADO Recordset Component
  47.             
  48.             Set oRs = Server.CreateObject("ADODB.Recordset")
  49.  
  50.  
  51.             ' Determine what PageNumber the scrolling currently is on
  52.             
  53.             Mv = Request("Mv")
  54.  
  55.             If Request("PageNo") = "" Then
  56.                 PageNo = 1
  57.             Else
  58.                 PageNo = Request("PageNo")
  59.             End If
  60.             
  61.             
  62.             ' Setup Query Recordset (4 records per page)
  63.                     
  64.             oRs.Open "SELECT * FROM Authors", oConn, adOpenStatic
  65.             oRs.PageSize = 4
  66.  
  67.             
  68.             ' Adjust PageNumber as Appropriate
  69.             
  70.             If Mv = "Page Up" or Mv = "Page Down" Then
  71.                 Select Case Mv
  72.                     Case "Page Up"
  73.                         If PageNo > 1 Then
  74.                             PageNo = PageNo - 1
  75.                         Else
  76.                             PageNo = 1
  77.                         End If
  78.                     Case "Page Down"
  79.                         If oRs.AbsolutePage < oRs.PageCount Then
  80.                             PageNo = PageNo + 1
  81.                         Else
  82.                             PageNo = oRs.PageCount
  83.                         End If
  84.                     Case Else
  85.                         PageNo = 1
  86.                 End Select
  87.             End If
  88.  
  89.             oRs.AbsolutePage = PageNo
  90.         %>
  91.  
  92.         
  93.         <!-- Draw Table of Contacts in DB -->
  94.  
  95.         <TABLE BORDER=1>
  96.             <%  For j = 1 to oRs.PageSize %>
  97.                 <TR>
  98.                     <%  For i = 0 to oRs.Fields.Count - 1 %>
  99.                         <TD VALIGN=TOP><%= oRs(i) %></TD>
  100.                     <%  Next %>
  101.                 </TR>
  102.  
  103.                 <%
  104.                     oRs.MoveNext
  105.                     
  106.                     ' Don't try to print the EOF record.
  107.                     If oRs.EOF Then
  108.                         Exit For
  109.                     End If
  110.                 Next %>
  111.         </TABLE>
  112.  
  113.  
  114.         <!-- Scrolling Navigation Control for Sample -->
  115.  
  116.         <Form Action=MultiScrolling_VBScript.asp Method="POST">
  117.             <Input Type="Hidden" Name="PageNo" Value="<%= PageNo %>">
  118.             <!-- Only show appropriate buttons -->
  119.             <%  If PageNo <  oRs.PageCount Then %>
  120.                 <INPUT TYPE="Submit" Name="Mv" Value="Page Down">
  121.             <%  End If %>
  122.  
  123.             <%  If PageNo > 1 Then %>
  124.                 <INPUT TYPE="Submit" Name="Mv" Value="Page Up">
  125.             <%  End If %>
  126.             
  127.         </Form>
  128.     </BODY>
  129. </HTML>
  130.