<%@ LANGUAGE = VBScript %> <% 'Dr. Thomas E. Hicks - Trinity University - File DisplayUser05.asp 'Display only the Name and No of all records from table Users of the Security Database 'in order by No. Select only those with No >- 3. 'Extremely Inefficient For Single Display! Query all info of all records! 'Use the Record Set approach! %> <% Option Explicit %> DisplayUser05.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 [No] " 'Create the Record Set Object Set UsersRecSet = Server.CreateObject ("ADODB.Recordset") 'Fill the UsersRecSet with the Results of the SQL Query Set UsersRecSet = Conn.Execute (Query) UsersRecSet.Filter = "No >= 3" %>
Display Name, No [No >= 3] by No- Inefficient - DisplayUser05.asp
Dr. Thomas E. Hicks Trinity University

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

<% UsersRecSet.MoveNext Loop ' Close the Connection. I try to close the connection asap. Conn.Close %>