home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / MultiScrolling_JScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  2.8 KB  |  146 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.             else
  61.             {
  62.                 PageNo = Request("PageNo");
  63.             }
  64.             
  65.             
  66.             // Setup Query Recordset (4 records per page)            
  67.  
  68.             oRs.Open ("SELECT * FROM Authors", oConn, adOpenStatic);
  69.             oRs.PageSize = 4;
  70.  
  71.             
  72.             // Adjust PageNumber as Appropriate
  73.  
  74.             if ((Mv == "PgUp") || (Mv == "PgDn"))
  75.             {
  76.                 if (Mv == "PgUp")
  77.                 {
  78.                     if (PageNo > 1)
  79.                     {
  80.                         PageNo = PageNo - 1;
  81.                     }
  82.                     else
  83.                     {
  84.                         PageNo = 1;
  85.                     }
  86.                 }
  87.                 else if (Mv == "PgDn")
  88.                 {
  89.                     if (oRs.AbsolutePage < oRs.PageCount)
  90.                     {
  91.                         PageNo = PageNo + 1;
  92.                     }
  93.                     else
  94.                     {
  95.                         PageNo = oRs.PageCount;
  96.                     }
  97.                 }
  98.                 else
  99.                 {
  100.                     PageNo = 1;
  101.                 }
  102.             }
  103.  
  104.             oRs.AbsolutePage = PageNo;
  105.         %>
  106.  
  107.         
  108.         <!-- Draw Table of Contacts in DB -->
  109.  
  110.         <TABLE BORDER=1>
  111.             <%  for (j = 0; j < oRs.PageSize; j++) { %>
  112.                 <TR>
  113.                     <%  for (i = 0; i < oRs.Fields.Count; i++) { %>
  114.                         <TD VALIGN=TOP><%= oRs(i) %></TD>
  115.                     <%  } %>
  116.                 </TR>
  117.  
  118.                 <%
  119.                     oRs.MoveNext()
  120.                     
  121.                     // Don't try to print the EOF record.
  122.                     if (oRs.EOF) {
  123.                         break;
  124.                     }
  125.                 } %>
  126.         </TABLE>
  127.  
  128.  
  129.         <!-- Scrolling Navigation Control for Sample -->
  130.  
  131.         <Form Action=MultiScrolling_VBScript.asp Method="POST">
  132.             <Input Type=Hidden Name= PageNo Value="<%= PageNo %>">
  133.             <%  if (PageNo > 1) { 
  134.                     // Only show buttons that are appropriate %>
  135.                     <INPUT TYPE="Submit" Name="Mv" Value="PgUp">
  136.             <%  } %>
  137.             
  138.             <%  if (PageNo <  oRs.PageCount) { 
  139.                     // Only show buttons that are appropriate %>
  140.                     <INPUT TYPE="Submit" Name="Mv" Value="PgDn">
  141.             <%  } %>
  142.         </Form>
  143.         
  144.     </BODY>
  145. </HTML>
  146.