Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Recordset problem

Posted 04 May 2004 21:24:28
1
has voted
04 May 2004 21:24:28 Claudio Huyskens posted:
I´m trying to create a recordset that shows datasets whose value "PLZ" is within a range of 1.000 of a specified value "Request.Form("PLZ"" [taken from a hidden form field]

I paste the code, its a classic ZIP code problem: If the ZIP code is within a certain range, then accept the dataset.

<%
Dim RSTest__MMColParam
RSTest__MMColParam = "%"
If (Request.Form("PLZ" <> "" Then
RSTest__MMColParam = Request.Form(PLZ) -1000
End If
%>
<%
Dim RSTest__MMColParam1
RSTest__MMColParam1 = "%"
If (Request.Form("PLZ" <> "" Then
RSTest__MMColParam1 = Request.Form(PLZ) +1000
End If
%>
<%
Dim RSTest
Dim RSTest_numRows

Set RSTest = Server.CreateObject("ADODB.Recordset"
RSTest.ActiveConnection = MM_Projekte_STRING
RSTest.Source = "SELECT * FROM Projekt WHERE '" + Replace(RSTest__MMColParam, "'", "''" + "' <= PLZ and '" + Replace(RSTest__MMColParam1, "'", "''" + "' >= PLZ"
RSTest.CursorType = 0
RSTest.CursorLocation = 2
RSTest.LockType = 1
RSTest.Open()

Replies

Replied 04 May 2004 22:39:18
04 May 2004 22:39:18 Claudio Huyskens replied:
obviously the only thing that doesn´t work is setting the variables RSTest_MMColParam and RSTest_MMColParam1 properly.

Is there another way to add or substract 1000 in the process of setting the variable?

I already tried it with QueryStrings that had added and substracted 1000 already and it worked. So it must be the adding and substracting of 1000 in the process of setting the variables.

I would greatly appreciate any comment or help.
Replied 04 May 2004 23:28:49
04 May 2004 23:28:49 Chad Cullum replied:
No value can satisfy BOTH of those criteria.

Try 'OR' vs. 'AND'

Replied 04 May 2004 23:31:42
04 May 2004 23:31:42 Chad Cullum replied:
EDIT: misread, still looking...



Replied 05 May 2004 15:33:09
05 May 2004 15:33:09 Vince Baker replied:
How about changing your sql where statement to the following:

Select *
from yourtable
where PLZ between (varPLZ+1000) and (varPLZ-1000)

set varPLZ as your URL value.



Regards
Vince

Visit my home: www.chez-vince.com

VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 05 May 2004 17:30:17
05 May 2004 17:30:17 Claudio Huyskens replied:
Thanks alot, works great! Didn´t know this workes in SQL

Reply to this topic