% Set objDC = Server.CreateObject("ADODB.Connection") objDC.Open Application("sample_connectionstring") 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") objDC.Open Application("sample_connectionstring") Set objRS = objDC.Execute("Select 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")
objDC.Open Application("sample_connectionstring")
Set objRS = objDC.Execute("Select * FROM Suppliers WHERE Country = '" & Request.Form("Country") & "' AND City = '" & Request.Form("city") & "'")
'Loop through the database and assign the appropriate values to variables
'that we will use later
Do Until objRS.EOF
CompanyName = objRS("CompanyName")
ContactName = objRS("ContactName")
Address = objRS("Address")
City = objRS("City")
Region = objRS("Region")
Zip = objRS("PostalCode")
Phone1 = objRS("Phone")
Fax1 = objRS("Fax")
Country = objRS("country")
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objDC.Close
Set objDC = Nothing
%>
Our Supplier in:
<% Response.Write City & ", " & Country %>
|