Mooks
11-04-2005, 10:07 AM
Hello All,
I have been pulling my hair out trying to work out what is wrong with my code.
I have a SQL database setup, with five columns.
I basically want the user to choose two drop down lists (Col001 and Col003) and the script will scan through the database to find the two matching columns, and give me the output on Col005.
Here is my code
This is Search.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/suburb.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_suburb_STRING
Recordset1.Source = "SELECT Suburb FROM dbo.suburb ORDER BY ID"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_suburb_STRING
Recordset2.Source = "SELECT Suburb FROM dbo.suburb ORDER BY ID"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>SUBURB DISTANCE SEARCH</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form ACTION="results.asp" METHOD="post" id="frmSubSearch" name="frmStatSearch">
<select name="form1" style="WIDTH: 200px; HEIGHT: 18px">
<%
Response.Write "<option VALUE="&chr(34) &"-----" &chr(34)
Response.Write ">" &"-ALL-"
while not Recordset1.EOF
Response.Write "<option VALUE="&chr(34)& Recordset1("Suburb")&chr(34)
Response.Write ">" & Recordset1("Suburb")
Recordset1.MoveNext
wend
%>
</select>
and
<select name="form2" style="WIDTH: 200px; HEIGHT: 18px">
<%
Response.Write "<option VALUE="&chr(34) &"-----" &chr(34)
Response.Write ">" &"-ALL-"
while not Recordset2.EOF
Response.Write "<option VALUE="&chr(34)& Recordset2("Suburb")&chr(34)
Response.Write ">" & Recordset2("Suburb")
Recordset2.MoveNext
wend
%>
</select>
<p> </p>
<input type="submit" name="Submit" value="Submit">
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
This is Results.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>SUBURB DISTANCE RESULTS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>Search Results for
<% Response.Write Request.Form("form1") %>
and
<% Response.Write Request.Form("form2") %>
=
<%Response.Write Request.Form("SELECT Col005 FROM dbo.sub_distmr_vic WHERE Col001 = '" &("form1") &"' AND Col003 = '" &("form2") &"'") %>
</p>
<p> </p>
<p> </p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
Any ideas;)
I have been pulling my hair out trying to work out what is wrong with my code.
I have a SQL database setup, with five columns.
I basically want the user to choose two drop down lists (Col001 and Col003) and the script will scan through the database to find the two matching columns, and give me the output on Col005.
Here is my code
This is Search.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/suburb.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_suburb_STRING
Recordset1.Source = "SELECT Suburb FROM dbo.suburb ORDER BY ID"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_suburb_STRING
Recordset2.Source = "SELECT Suburb FROM dbo.suburb ORDER BY ID"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>SUBURB DISTANCE SEARCH</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form ACTION="results.asp" METHOD="post" id="frmSubSearch" name="frmStatSearch">
<select name="form1" style="WIDTH: 200px; HEIGHT: 18px">
<%
Response.Write "<option VALUE="&chr(34) &"-----" &chr(34)
Response.Write ">" &"-ALL-"
while not Recordset1.EOF
Response.Write "<option VALUE="&chr(34)& Recordset1("Suburb")&chr(34)
Response.Write ">" & Recordset1("Suburb")
Recordset1.MoveNext
wend
%>
</select>
and
<select name="form2" style="WIDTH: 200px; HEIGHT: 18px">
<%
Response.Write "<option VALUE="&chr(34) &"-----" &chr(34)
Response.Write ">" &"-ALL-"
while not Recordset2.EOF
Response.Write "<option VALUE="&chr(34)& Recordset2("Suburb")&chr(34)
Response.Write ">" & Recordset2("Suburb")
Recordset2.MoveNext
wend
%>
</select>
<p> </p>
<input type="submit" name="Submit" value="Submit">
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
This is Results.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>SUBURB DISTANCE RESULTS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>Search Results for
<% Response.Write Request.Form("form1") %>
and
<% Response.Write Request.Form("form2") %>
=
<%Response.Write Request.Form("SELECT Col005 FROM dbo.sub_distmr_vic WHERE Col001 = '" &("form1") &"' AND Col003 = '" &("form2") &"'") %>
</p>
<p> </p>
<p> </p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
Any ideas;)