<% Set objDC = Server.CreateObject("ADODB.Connection") strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database/northwind.mdb") objDC.Open strConn Set objRS = objDC.Execute("Select Distinct Country FROM Suppliers") %>

 

Choose a Country

<% ' Close Data Access Objects and free DB variables objRS.Close Set objRS = Nothing objDC.Close Set objDC = Nothing %> <% 'Some code to hide the second drop down until we make a selection from the first IF Request.Form("Country") = "" Then Else 'If Country has a value then we get a list of cities for the second drop down Set objDC = Server.CreateObject("ADODB.Connection") strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database/northwind.mdb") objDC.Open strConn Set objRS = objDC.Execute("Select DISTINCT City FROM Suppliers WHERE Country = '" & Request.Form("Country") & "'") %>

Choose a City">

<% ' Close Data Access Objects and free DB variables objRS.Close Set objRS = Nothing objDC.Close Set objDC = Nothing End IF %>
  <% 'Make sure we have submitted a city and don't show results until we do IF Request.Form("city") = "" Then Else Set objDC = Server.CreateObject("ADODB.Connection") strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database/northwind.mdb") objDC.Open strConn Set objRS = objDC.Execute("Select * FROM Suppliers WHERE Country = '" & Request.Form("Country") & "' AND City = '" & Request.Form("city") & "'") %>

Our Supplier in: <% Response.Write objRS("City") & ", " & objRS("country") %>
<% Do until objRS.EOF 'Set up the display of the record Response.Write objRS("CompanyName") & "
" Response.Write objRS("ContactName") & "
" Response.Write objRS("Address") & "
" Response.Write objRS("City") & ", " & objRS("Region") & " " & objRS("PostalCode") & "
" Response.Write "Phone: " & objRS("Phone") & "

" objrs.movenext loop objRS.Close Set objRS = Nothing objDC.Close Set objDC = Nothing End IF %>