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

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