Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql requesting from form

Status
Not open for further replies.

farazmit

Programmer
Jan 3, 2005
14
0
0
US
Hi
I have the following sql statement which uses a form drop down list in the Where Statement.
However, I get an error saying
Object doesn't support this property or method.

Recordset2.Source = "SELECT BusName FROM BusinessInfo WHERE City = '"+ Request.form1("select") +"'";

Here is the form from which I am requesting a value in the above where statement(the form is working, I just put it for its name and the name of select list.

<form name="form1" method="post" action="">
<select name="select" >
<%
while (!Recordset1.EOF) {
%>
<option value="<%=(Recordset1.Fields.Item ("City").Value)%>">
<%=(Recordset1.Fields.Item("City").Value)%></option>
<%
Recordset1.MoveNext();
}
if (Recordset1.CursorType > 0) {
if (!Recordset1.BOF) Recordset1.MoveFirst();
} else {
Recordset1.Requery();
}
%>
</select>

PLease help :)
Thanks



 
Recordset2.Source = "SELECT BusName FROM BusinessInfo WHERE City = '"+ Request.form1("select") +"'";

"CITY" is not is your query - Only "BusName"

Code:
Recordset2.Source = "SELECT BusName, [highlight]city[/highlight] FROM BusinessInfo WHERE City = '"+ Request.form1("select") +"'";

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

zen.gif

 
I have another connection for the city
I just didn't want to write the whole code
my problem is within the request
Thanks again
 
If this line is throwing the error
[blue]Recordset2.Source = "SELECT BusName FROM BusinessInfo WHERE City = '"+ Request.form1("select") +"'";[/blue]

Then I think that maybe you haven't created recordset2 correctly - can you show the code where you create it?
ie - [red]set recordset2 = server.createObject("adodb.recordset")[/red]



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

zen.gif

 
what do you get if you place this before the query

<code>Response.write request.form1("select")
response.end
</code>
 
let me try that again... new to making my posts pretty.

Code:
Response.write request.form1("select")
response.end
 
Here is my connection:
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_VooplaV1_STRING;
Recordset1.Source = "SELECT * FROM CityLookup";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
I think this is fine cause I can try everything without
the above where statement.
I tried putting
Response.write request.form1("select")
response.end
in from of where clause but it still gives me error.
Thanks alot for your help though
 
oh here is the connection for recordset2:
<%
var Recordset2 = Server.CreateObject("ADODB.Recordset");
Recordset2.ActiveConnection = MM_VooplaV1_STRING;
//selecteditem = M();

Recordset2.Source = "SELECT BusName FROM BusinessInfo WHERE City = '"+ Response.write request.form1("select")
response.end +"'";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 1;
Recordset2.Open();
var Recordset2_numRows = 0;
%>
 
I meant putting the response.write stuff before you try to open any recordset. Are you indeed passing "select" from your previous form and requesting it successfully?
Code:
Response.write request.form1("select")
response.end

var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_VooplaV1_STRING;
Recordset1.Source = "SELECT * FROM CityLookup";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;

what should happen is you should see the value of "select" and nothing else as the script will stop before the rest.
 
I believe it should be Request.Form("select") since form1 is the name of the form, not an property within the Request object.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top