SQL Query trouble

hello all,
I have a form with multiple chechboxes. Depending upon what the user chooses
I need to make a select from a database with 6 tables. I pass the results
from the form to the SQL statement up to the moment I need to put in a where
request.form>0 clause. The big issue is that the request form may look like
str1,str2,str3,str4 if the user selects them all.

Maybe u can help because I'm completely lost.
Here is the code:
------FORM------
<form action="processquery.asp" name="formfilter" Method="Post">
<table border="0" bordercolor="#0033CC" cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td width="100%">Choose County
</td>
</tr>

<tr>
<td width="100%">
<input type="checkbox" name="Judet" value="Alba"> Alba  
<input type="checkbox" name="Judet" value="Arges"> Arges  
<input type="checkbox" name="Judet" value="Arad"> Arad  
<input type="checkbox" name="Judet" value="Braila"> Braila  
<input type="checkbox" name="Judet" value="Botosani"> Botosani  
<input type="checkbox" name="Judet" value="Brasov"> Brasov  
<input type="checkbox" name="Judet" value="Buzau"> Buzau  
<input type="checkbox" name="Judet" value="Cluj"> Cluj  
<input type="checkbox" name="Judet" value="Calarasi"> Calarasi  
</td>
</tr>
<tr>
<td width="100%">Choose Culture
</td>
</tr>
<tr>
<td width="100%">
<input type="checkbox" name="Cultura" value="Sgrau"> Grau  
<input type="checkbox" name="Cultura" value="Sporumb"> Porumb  
<input type="checkbox" name="Cultura" value="Sfloare"> Floare  
<input type="checkbox" name="Cultura" value="Srapita"> Rapita  
<input type="checkbox" name="Cultura" value="Ssoia"> Soia  
</td>
</tr>

<tr>
<td width="100%>Choose Source
</td>
</tr>
<tr>
<td width="100%">
<input type="checkbox" name="Sursa" value="Dir.Agricola"> Directia Agricola
 
<input type="checkbox" name="Sursa" value="Simpozion"> Simpozion  
<input type="checkbox" name="Sursa" value="APIA"> APIA  
<input type="checkbox" name="Sursa" value="Altele"> Altele  
</td>
</tr>

<tr>
<td width="100%" align="center" valign="middle">

<BR /><input type="reset" name="Reset" value="Reset">  <input
type="submit" name="Submit" value="Add Contact">
</form>

---------processquery.asp--------------

<%
dim strjudet,strcultura,strsursa

strjudet=request("Judet")
strjudet=Replace(strjudet, ",","','")
strjudet=Replace(strjudet, " ","")
strsursa=request("Sursa")
strsursa=Replace(strsursa, ",","','")
strsursa=Replace(strsursa, " ","")



strcultura=request("Cultura")
%>
<%
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = Conn

'SQL = "SELECT * FROM Customer INNER JOIN Address ON Customer.ID=Address.ID
INNER JOIN FarmDetails ON Address.ID=FarmDetails.ID WHERE Address.County IN
('"&strjudet&"')"
SQL = "SELECT * FROM Customer,Address,FarmDetails,InfoDetails WHERE Customer.
ID=Address.ID AND Customer.ID=FarmDetails.ID AND Customer.ID=InfoDetails.ID
AND Address.County IN ('"&strjudet&"') AND Source IN ('"&strsursa&"') AND
each Item in strcultura>0"????how do I go about that?

RS.Open SQL, Conn, 1, 3




If NOT (RS.BOF AND RS.EOF) Then%>

<% While (NOT RS.EOF)

%>


Thanks
marauder78 [ Do, 17 Januar 2008 21:30 ] [ ID #1910636 ]

Re: SQL Query trouble

you will need to test for each selected value and then build up a WHERE clause according to the results.

then append the constructed WHERE clause into your SQL statement
Jon Paal [ Fr, 18 Januar 2008 22:25 ] [ ID #1911447 ]
Webserver » microsoft.public.inetserver.asp.general » SQL Query trouble

Vorheriges Thema: String truncated
Nächstes Thema: How do you check a value exists in an array?