<%@ Language=VBScript %>
<%
Dim conn, rst, strSQL
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 15
conn.CommandTimeout = 30
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & _
    Server.MapPath("Northwind.mdb") & ";"
Set rst = Server.CreateObject("ADODB.Recordset")
If Len(Request.QueryString("ProductID")) <> 0 Then
    strSQL="SELECT * FROM Products WHERE ProductID="
    rst.Open(strSQL & Request.QueryString("ProductID")), conn, 0, 1
    If Not rst.EOF Then
        rst.MoveFirst
        Response.Write "<TABLE Border=1>"
        Response.Write "<TR>"
        Response.Write "<TD><B>Product ID</B></TD>"
        Response.Write "<TD><B>Product Name</B></TD>"
        Response.Write "<TD><B>Quantity Per Unit</B></TD>"
        Response.Write "<TD><B>Units in Stock</B></TD>"
        Response.Write "<TD><B>Unit Price</B></TD>"
        Response.Write "</TR>"
        Response.Write "<TR>"
        Response.Write "<TD Align='Center'>"
        Response.Write rst.Fields("ProductID") & "</TD>"
        Response.Write "<TD Align='Left'>"
        Response.Write rst.Fields("ProductName") & "</TD>"
        Response.Write "<TD Align='Left'>"
        Response.Write rst.Fields("QuantityPerUnit") & "</TD>"
        Response.Write "<TD Align='Center'>"
        Response.Write rst.Fields("UnitsInStock") & "</TD>"
        Response.Write "<TD Align='Right'>"
        Response.Write FormatCurrency(rst.Fields("UnitPrice"),2) & "</TD>"
        Response.Write "</TR>"
        Response.Write "</TABLE>"
    End If
    rst.Close
End If
rst.Open "Products", conn, 0, 1
If Not rst.EOF Then
    rst.MoveFirst
    Response.Write "<FORM Action='./ProductLookup.asp' Method='get'>"
    Response.Write "<B>Select a Product:</B><BR>"
    Response.Write "<SELECT Name='ProductID'>"
    Response.Write "<OPTION></OPTION>"
    Do While Not rst.EOF
        Response.Write "<OPTION value=" & rst.Fields("ProductID") & ">"
        Response.Write rst.Fields("ProductName") & "</OPTION>"
        rst.MoveNext
    Loop
    Response.Write "</SELECT>"
    Response.Write "<INPUT Type='Submit' Value='Get Product Details'>"
    Response.Write "</FORM>"
End If
rst.Close
Set rst =  Nothing
conn.Close
Set conn = Nothing
%>
