% 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") %>
| <% ' 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") & "'") %> <% ' 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") %>
|