SQLTeam.com | Weblogs | Forums

Using BETWEEN statement in HTML/ASP page

I'm trying to use the BETWEEN statement in .ASP page that is pulling information from two text boxes. I'm trying to find values between the same column. However, the server keeps giving me a 500 server error. What's wrong with the query statement ? I must be doing something wrong. Here's the code:

stockval = replace(trim(Request.Form("txtFrom")),"'","''")
stockval2 = replace(trim(Request.Form("txtTo")),"'","''")

strSQL = "SELECT * FROM FBase WHERE Rating BETWEEN & 'stockval='" & "stockval2='" & "'"

What do you see when you print or echo or console.log strSQL

First try hardcoded values:

strSQL = "SELECT * FROM FBase WHERE Rating BETWEEN 1 AND 2"

replace the 1 with the value stockval and if that works replace the 2 by stockval2. You should try to figure out what happens when stockval is greater then stockval2.