<!--#include file="./includes/sql.asp"-->
<%
Response.Write("<h1>Production Printer Machines Count</h1>")

Dim strSQL, rs

' Count printer machines
strSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinetypeid = 15"
set rs = objConn.Execute(strSQL)
Response.Write("<h3>Machines with Printer type (machinetypeid=15): " & rs("cnt") & "</h3>")
rs.Close

' Count machines with -PRINTER suffix
strSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinenumber LIKE '%-PRINTER'"
set rs = objConn.Execute(strSQL)
Response.Write("<h3>Machines with '-PRINTER' suffix: " & rs("cnt") & "</h3>")
rs.Close

' Show sample
Response.Write("<h3>Sample Printer Machines:</h3>")
strSQL = "SELECT m.machineid, m.machinenumber, m.alias, c.address as ipaddress " &_
         "FROM machines m " &_
         "LEFT JOIN communications c ON m.machineid = c.machineid AND c.comstypeid = 1 " &_
         "WHERE m.machinetypeid = 15 " &_
         "ORDER BY m.machineid DESC LIMIT 10"
set rs = objConn.Execute(strSQL)
Response.Write("<table border='1' style='border-collapse:collapse'>")
Response.Write("<tr><th>ID</th><th>Machine Number</th><th>Alias</th><th>IP</th></tr>")
While Not rs.EOF
    Response.Write("<tr>")
    Response.Write("<td>" & rs("machineid") & "</td>")
    Response.Write("<td>" & Server.HTMLEncode(rs("machinenumber") & "") & "</td>")
    Response.Write("<td>" & Server.HTMLEncode(rs("alias") & "") & "</td>")
    Response.Write("<td>" & Server.HTMLEncode(rs("ipaddress") & "") & "</td>")
    Response.Write("</tr>")
    rs.MoveNext
Wend
Response.Write("</table>")
rs.Close

objConn.Close
%>
