This example uses the CacheSize property to show the difference in performance for an operation performed with and without a 30-record cache.
<!-- BeginCacheSizeJS --> <%@ Language="JScript" %> <!-- Include file for JScript ADO Constants --> <!--#include File="adojavas.inc"--> <HTML> <HEAD> <title>CacheSize Property Example (JScript)</title> <style> <!-- body { font-family: 'Verdana','Arial','Helvetica',sans-serif; BACKGROUND-COLOR:white; COLOR:black; } .thead2 { background-color: #800000; font-family: 'Verdana','Arial','Helvetica',sans-serif; font-size: x-small; color: white; } .tbody { text-align: center; background-color: #f7efde; font-family: 'Verdana','Arial','Helvetica',sans-serif; font-size: x-small; } --> </style> </HEAD> <BODY> <h1>CacheSize Property Example (JScript)</h1> <% // Don't forget to change the settings for Data Source, // User ID, and Password to match the settings on your server. var Connect = "Provider=sqloledb;Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" + "Initial Catalog=Northwind;User Id=sa;Password=;" // Open a recordset on the Employee table using // a client-side cursor. var rsCustomer = Server.CreateObject("ADODB.Recordset"); rsCustomer.CursorLocation = adUseClient; rsCustomer.Open("Customers", Connect); var Now = new Date(); var sngStart = Now.getTime(); // Enumerate the recordset 20 times. for (var i=1; i<=20; i++) { rsCustomer.MoveFirst(); while (!rsCustomer.EOF) { // Do something with the record. var strTemp = new String(rsCustomer.Fields("title_id")); rsCustomer.MoveNext(); } } Now = new Date(); var sngEnd = Now.getTime(); var sngNoCache = sngEnd - sngStart; // Cache records in groups of 30. rsCustomer.MoveFirst(); rsCustomer.CacheSize = 30; Now = new Date(); sngStart = Now.getTime(); // Enumerate the recordset 20 times. for (var i=1; i<=20; i++) { rsCustomer.MoveFirst(); while (!rsCustomer.EOF) { // Do something with the record. var strTemp = new String(rsCustomer.Fields("title_id")); rsCustomer.MoveNext(); } } Now = new Date(); sngEnd = Now.getTime(); var sngCache = sngEnd - sngStart; %> <table border="2"> <tr class="thead2"> <th>No Cache</th> <th>30 Record Cache</th> </tr> <tr class="tbody"> <td><%=sngNoCache%></td> <td><%=sngCache%></td> </tr> </table> </BODY> </HTML> <!-- EndCacheSizeJS -->
CacheSize Property | Recordset Object