<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual="/mst3k/adovbs.inc"-->

<html>
<head>
<title>Inventory</title>
</head>
<body>

<%
' make a database connection
Dim myDBConnection
Dim myDriverInfo

Set myDBConnection = Server.CreateObject("ADODB.Connection")
myDriverInfo = _

"Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=f:\web\database\mst3k\Inventory.mdb"

myDBConnection.Open myDriverInfo

'Instantiate an ADO Recordset object
Dim inventoryList
Set inventoryList = _

Server.CreateObject("ADODB.Recordset")

inventoryList.ActiveConnection = myDriverInfo
inventoryList.CursorType = adOpenStatic

Dim SQLQuery
SQLQuery = _

"SELECT Inventory.InventoryID, Inventory.DateAcquired, Inventory.Comments, " _
    & "Employees.FirstName, Employees.LastName, Computers.ComputerDescription " _
    & "FROM Inventory, Employees, Computers " _
    & "WHERE ((Inventory.EmployeeID = Employees.EmployeeID) " _
    & "and (Inventory.ComputerID = Computers.ComputerID)) " _
    & "ORDER BY Employees.LastName, Employees.FirstName"

inventoryList.open SQLQuery
%>

Records in the inventory:<p>

<%
' Use the EOF property to loop through the records in the recordset
Do While Not inventoryList.EOF

Response.Write inventoryList("LastName") & ", " _
    & inventoryList("FirstName") & ", " _
    & inventoryList("ComputerDescription") & ", " _
    & inventoryList("DateAcquired") & ", " _
    & inventoryList("Comments") & "<br>"
inventoryList.MoveNext

Loop

' Close everything and release the memory consumed by the objects
inventoryList.Close
Set inventoryList = Nothing
myDBConnection.Close
Set myDBConnection = Nothing
%>

</body>
</html>