# sql query using form in ASP



## Bally (Feb 24, 2001)

Hi,

I'm having a problem with a search sql query in asp using criteria selected(from drop down menus)in a form. I keep getting an error saying message saying too few parameter or their is an error with the datbase(its working fine) When i do the query with just one of the criteria it works fine but when i try to do it with all six, it never works!
Can anyone help?
Thanks

this is a bit of my code :

dim ar, prop, beds (6 variables altogether)

ar = Request.Form("Area")
prop = Request.Form("PropertyType")
beds = Request.Form("Bedrooms)

query = "SELECT * FROM Properties" _ 
& "WHERE Area = ("'&ar&'")" _ 
& "PropertyType = ("'&prop&'")" _ 
& "Bedrooms = ("'&beds&'")" 

Set RS=dbConn.Execute(query)


----------



## YSB (Mar 7, 1999)

Between each criteria you need to put the word "AND" with a space before it so it doesn't get concatenated with the last criteria. There should also be a space before the word 'Where' or it will be connected to the word 'Properties' on the line before. One more point, if you want the SQL statement to come out with the contents of the variables enclosed in quotes then the single quotes should be *inside* the double quotes. The SQL statement should look like this:

query = "SELECT * FROM Properties" _
& " WHERE Area = ('" & ar & "')" _
& " AND PropertyType = ('" & prop & ")" _
& " AND Bedrooms = ('" & beds & "')"

That should do it. Let us know how it works. Good Luck!


----------

