<%@ LANGUAGE = "VBScript" %> <% Option Explicit %>

Software Database: current status

<% 'Start ASP scripting 'Declare the one and only global variable, the DB connection DIM conn 'Open ODBC connection with Catalogue Set conn = Server.CreateObject("ADODB.Connection") conn.Open "swdb" 'Run subroutine SoftwareDBInfo 'Close ODBC connection conn.close 'Release memory used by connection set conn = nothing %>

Software Database home

<% Sub SoftwareDBInfo 'Print basic info on current status of SWDB: number of records, last updated DIM sql, rs, swRecCount, suppRecCount, swUpdate, suppUpdate 'Instantiate recordset object set rs = Server.CreateObject("ADODB.Recordset") 'Create simple query on software table sql = "SELECT sw_num, date_updated FROM software;" 'Run query, using adOpenStatic as cursor. This allows forward and backward scrolling in the recordset. The default is adOpenForwardOnly. rs.open sql, conn, adOpenStatic 'Get number of records... swRecCount = rs.recordcount '...then get date of last updated record swUpdate = rs("date_updated") do while not rs.eof if rs("date_updated") > swUpdate then swUpdate = rs("date_updated") end if rs.movenext loop 'Close recordset rs.close 'Do another query, this time on the supplier table, and put results 'in same recordset variable sql = "SELECT supplier_num, date_updated FROM supplier;" rs.open sql, conn, adOpenStatic 'Get number of records... suppRecCount = rs.recordcount '...then get date of last updated record suppUpdate = rs("date_updated") do while not rs.eof if rs("date_updated") > suppUpdate then suppUpdate = rs("date_updated") end if rs.movenext loop 'Print results as table, using DateConvert() to put dates into 'European dd/mm/yyyy format. %>
  Software Suppliers
Records <%=swRecCount%> <%=suppRecCount%>
Last update <%=dateConvert(swUpdate)%> <%=dateConvert(suppUpdate)%>
<% 'Close recordset rs.close 'Free up memory used by recordset set rs = nothing End Sub %> <% Function DateConvert(inDate) 'Convert date in mm/dd/yy to dd/mm/yy DateConvert = Day(inDate) & "/" & Month(inDate) & "/" & Year (inDate) End Function %>