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

  1. <%@ LANGUAGE = JScript  %>
  2.  
  3. <!--#include file="adojavas.inc"-->
  4.  
  5. <HTML>
  6.     <HEAD>
  7.         <TITLE>LimitRows From Database</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>LimitRows From Database</b></font><br>
  17.     
  18.         <hr size="1" color="#000000">
  19.  
  20.         Contacts within the Authors Database:<br><br>
  21.  
  22.         <%
  23.             var oConn;    
  24.             var oRs;    
  25.             var curDir;    
  26.             var Index;    
  27.  
  28.             
  29.             // Map authors database to physical path
  30.             
  31.             curDir = Server.MapPath("\\iissamples\\sdk\\asp\\database\\authors.mdb");
  32.  
  33.  
  34.             // Create ADO Connection Component to connect
  35.             // with sample database
  36.             
  37.             oConn = Server.CreateObject("ADODB.Connection");
  38.             oConn.Open("DBQ="+curDir+";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;");
  39.         
  40.         
  41.             // Create ADO Recordset Component
  42.             
  43.             oRs = Server.CreateObject("ADODB.Recordset");
  44.             oRs.ActiveConnection = oConn;
  45.             
  46.             
  47.             // Set Recordset PageSize so that it only holds 10 rows
  48.             
  49.             oRs.PageSize = 10;
  50.             
  51.             
  52.             // Get recordset
  53.             
  54.             oRs.Source = "SELECT * FROM authors";
  55.             oRs.CursorType = adOpenStatic;
  56.             
  57.             
  58.             // Open Recordset
  59.             
  60.             oRs.Open();
  61.         %>
  62.  
  63.  
  64.         <TABLE border = 1>
  65.         <%  
  66.             var RecordCount;
  67.             RecordCount = 0;
  68.         
  69.             while ((!oRs.eof) && (RecordCount < oRs.PageSize)) { %>
  70.  
  71.                 <tr>
  72.                     <% for(Index=0; Index < oRs.fields.count; Index++) { %>
  73.                         <TD VAlign=top><% = oRs(Index)%></TD>
  74.                     <% } %>
  75.                 </tr>
  76.             
  77.                 <%
  78.                     RecordCount = RecordCount + 1;
  79.                     oRs.MoveNext(); 
  80.             } 
  81.         %>
  82.  
  83.         </TABLE>
  84.  
  85.  
  86.         <%   
  87.             oRs.Close();
  88.             oConn.Close();
  89.         %>
  90.  
  91.     </BODY>
  92. </HTML>
  93.