<%@ LANGUAGE = VBScript %> <% 'Dr. Thomas E. Hicks - Trinity University - File DisplayUser06.asp 'Display only the Name and No of all records from table Users of the Security Database 'in ascending order by Name. First display those with No >-=3. 'Second Display Name and IDNo of all records in which the 2 <= IDNo <= 4. 'Extremely Inefficient For Single Display! Query all info of all records! 'Third display only the Name [decending order] but skip Tom! 'Use the Record Set approach! %> <% Option Explicit %> DisplayUser06.asp <% Dim Conn, UsersRecSet, Query 'Create a Connection Object Set Conn = Server.CreateObject ("ADODB.Connection") 'Open Security ODBC with the Connection Object Conn.Open "Security" 'Define the Query - declared as a variable because often long! Query = "SELECT * FROM Users ORDER BY [Name] " 'Create the Record Set Object Set UsersRecSet = Server.CreateObject ("ADODB.Recordset") 'Fill the UsersRecSet with the Results of the SQL Query 'This approach allows us to select the open method. 'adOpenStatic - Select executed - when others change database - my copy not changed. 'adOpenFrowardOnly [ default] - static and forward only [No MovePrevious or Move -2] 'adDynamic - Select executed - when others change database my copy changed! [overhead!] UsersRecSet.Open Query, Conn, adOpenStatic %>
Multi-Processing of Record Set - DisplayUser06.asp
Dr. Thomas E. Hicks Trinity University

Name & No of those with No >= 3

<% UsersRecSet.Filter = "No >= 3" Do Until UsersRecSet.EOF %> Name : <% = UsersRecSet ("NAME") %>
No : <% = UsersRecSet ("NO") %>

<% UsersRecSet.MoveNext Loop %>
Name & No of those with <=2 IDNo <= 4

<% UsersRecSet.Filter = "IDNo >= 2 AND IDNo <= 4" ' Methods to MoveFirst, MoveLast, MoveNext, MovePrevious, Move xx [#] UsersRecSet.MoveFirst Do Until UsersRecSet.EOF %> Name : <% = UsersRecSet ("NAME") %>
ID No : <% = UsersRecSet ("IDNO") %>

<% UsersRecSet.MoveNext Loop%>
Name [DESC] skip Tom

<% UsersRecSet.Filter = "Name <> 'Tom'" UsersRecSet.MoveLast Do Until UsersRecSet.BOF %> Name : <% = UsersRecSet ("NAME") %>
<% UsersRecSet.MovePrevious Loop ' Close the Connection. I try to close the connection asap. Conn.Close %>