SQL Problem with multiple values
HI,
I am working on a dynamic query and for the most part it is working - however - in the form users have the ability to select multiple values in any particular column - the problem is that when multiple values are selected the query fails to return any results - when only one value per column is slected results will be retrieved. I have been trying to work with an IN statement to have it parse the multiple values - but I have probably messed up somewhere:
Here is the code:
sqlstr = "SELECT * FROM tblsamples WHERE Date_Stored BETWEEN #" + rssample__varstorefrom + "# AND #" + rssample__varstoreto + "#"
rssample__vartower = "*"
If (Request.Form("tower") <> "") Then
rssample__vartower = Request.Form("tower")
If rssample__vartower <> "*" then
sqlstr= sqlstr + " and Tower IN('" + rssample__vartower + "') "
End if
End If
Here is the SQL string that is passed to the page:
SQL is SELECT * FROM tblsamples WHERE Date_Stored BETWEEN #01/01/2005# AND #06/27/2005# and Tower=('01, 02, 03')
by the way - the database is setup so that the field Tower is a text field.
Any help would be appreciated - I am still very new to asp programming
Chris
|