GRQNET
|
Posted: 05/28/2004, 12:00 PM |
|
Hi, I'm a newbe to programming.
I am attempting to create a List Box that allows the user to do a muliple
selection of towns and be able to display any of the results search for.
Right now my code just does an AND function. That is if I select the towns
Greenlawn and Melville, the search results show nothing instead of BOTH
towns.
I am using ASP.
Here is my SQL code for the table.
SELECT DISTINCT c21aalistings.new_bath_tot, c21aalistings.ml_link,
c21aalistings.bath_full, c21aalistings.bath_half, c21aalistings.bath_tot,
c21aalistings.br, c21aalistings.constr, c21aalistings.county,
c21aalistings.lp_dol, c21aalistings.ml_num, c21aalistings.sd_name,
c21aalistings.sd_num, c21aalistings.style, c21aalistings.taxes,
c21aalistings.town FROM c21aalistings LEFT JOIN NassauTowns ON
c21aalistings.town = NassauTowns.town
WHERE (NassauTowns.town IN ('{s_nassautown}') OR ('{s_nassautown}'='0') )
I notice that if I change the code to what the CodeCharge ExamplePack says.
SELECT DISTINCT c21aalistings.new_bath_tot, c21aalistings.ml_link,
c21aalistings.bath_full, c21aalistings.bath_half, c21aalistings.bath_tot,
c21aalistings.br, c21aalistings.constr, c21aalistings.county,
c21aalistings.lp_dol, c21aalistings.ml_num, c21aalistings.sd_name,
c21aalistings.sd_num, c21aalistings.style, c21aalistings.taxes,
c21aalistings.town FROM c21aalistings LEFT JOIN NassauTowns ON
c21aalistings.town = NassauTowns.town
WHERE (NassauTowns.town IN ({s_nassautown}) OR ('{s_nassautown}'='0') )
(I removed the quotes around the first {s_nassautown} )
I get the following error:
Form: Grid c21aalistings
Error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
Expected 2. (Microsoft OLE DB Provider for ODBC Drivers)
Anthony
Thanks in advance for the help!!
|
|
|
Bruce Van Horn
|
Posted: 07/13/2004, 2:57 PM |
|
Geez, that sql is a mouthful. It might be easier to find the problem if you break it down a bit. Depending on what database you are using, you should make a view with everything up to the where clause.
See if that works. It probably will. Then call the view with the where clause. Then you need only worry about problems in the where clause.
I suspect the problem is caused by your quote removal.
Is_nassautown a number or a string? if its a string (letters) then it must have the quotes or the query will fail. The way CC works is it looks for anything in {brackets} and replaces it with data from your app. so WHERE myword='{my_word}' is replaced with a value and so becomes WHERE myword='howdy' assuming that's the value of the variable my_word. if you take the quotes out, howdy becomes myword=howdy -- and howdy becomes to a microsoft database; a parameter which of course you don't have.
hope that works out.
|
|
|
|