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

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