home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_06.cab / samp3reb.asp < prev    next >
Text File  |  1997-09-29  |  3KB  |  44 lines

  1.  <% If Request("DontFrame")<>1 Then Response.Redirect "/iissamples/sdk/asp/docs/SampFram.asp?ovfile=/iishelp/iis/htm/sdk/samp3reb.asp&srcfile=Database/LimitRows" %>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  3. <HTML>
  4. <HEAD>
  5. <META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
  6. <title>Limit Query Results</title>
  7. <script language="JavaScript">
  8.  
  9.     szNavVersion = navigator.appVersion
  10.  
  11.     if (navigator.appName == "Microsoft Internet Explorer") {
  12.     if (szNavVersion.indexOf ("4.") >= 0) {
  13.         document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie4.css">');
  14.     } else {
  15.         document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie3.css">');
  16.     }
  17.     }
  18.     else if (navigator.appName == "Netscape") {
  19.     document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie4.css">');
  20.     }
  21.     else {
  22.     document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie3.css">');
  23.     }
  24.  
  25. </script>
  26. <META NAME="DESCRIPTION" CONTENT="Internet Information Server reference information"></HEAD>
  27. <BODY BGCOLOR=#FFFFFF TEXT=#000000>
  28. <font face="Verdana, Arial, Helvetica">
  29. <h3><a name="_limit_query_results"></a>Limit Query Results</h3>
  30. <p>
  31. In an Internet environment, it is often desirable to limit the amount of information that a database query returns to a client browser. This example demonstrates how a script, using ASP and ADO, can limit the number of rows returned.</p>
  32. <p>
  33. The sample first creates an instance of the <b>Connection</b> object, and opens the ODBC connection with the this object's <b>Open</b> method. <b>CreateObject</b> is used again to instantiate an empty <b>Recordset</b> object. The <b>ActiveConnection</b> property of the new <b>Recordset</b> object is set to point at the open ODBC connection, an SQL source string is assigned, and cursor type specified. The key to limiting the results lies with the <b>Recordset</b> object's <b>PageSize</b> property. For this example, the value is set to 10, which indicates that ADO is to return at most 10 records. Finally, the <b>Open</b> method is called, and ADO searches for the first 10 records that fulfill the SQL search string. </p>
  34. <p>
  35. When ADO has returned and placed the results of the search into the <b>Recordset</b> object, the script loops through the page, displaying all fields of each record in a table. The script then performs the typical housecleaning operations, closing both the recordset and the connection. </p>
  36. <p>
  37. It is important to realize that if the SQL query had returned more than 10 records, this script would not display them. The property <b>PageCount</b> would need to be accessed to discover how many logical pages of data were returned. </p>
  38. <p>
  39. <b>Note</b>  ODBC must be properly configured on the server before this sample will run properly. </p>
  40. <hr class="iis" size="1">
  41. <p align="center"><em><a href="/iishelp/common/colegal.htm">© 1997 by Microsoft Corporation. All rights reserved.</a></em></p>
  42. </BODY>
  43. </HTML>
  44.