mann95 Posted December 24, 2005 Share Posted December 24, 2005 I'm trying to create a search facility which will allow users to find products according to price. I have created two drop down menus which will allow users to search between two values. I have assigned the variable name "lowstring" to the first drop menu and "highstring" to the second drop down menu. The two variables are being taken from the form successfully. I am not sure whether i have written the sql correctly or if I should have used a less than and greater than. <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("\n0253071\db\assignment1.mdb"))set rs = Server.CreateObject("ADODB.recordset")lowstring=Request.form("lower")highstring=Request.form("higher")rs.Open "SELECT * FROM Books WHERE Price BETWEEN '%" & highstring & "%' AND '%" & lowstring & "%' ORDER BY BookTitle",conn%> Any help much appreciatedCheersCM Link to comment Share on other sites More sharing options...
asko1981 Posted January 3, 2006 Share Posted January 3, 2006 I would use the < > signs. I'm trying to create a search facility which will allow users to find products according to price. I have created two drop down menus which will allow users to search between two values. I have assigned the variable name "lowstring" to the first drop menu and "highstring" to the second drop down menu. The two variables are being taken from the form successfully. I am not sure whether i have written the sql correctly or if I should have used a less than and greater than.<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("\n0253071\db\assignment1.mdb"))set rs = Server.CreateObject("ADODB.recordset")lowstring=Request.form("lower")highstring=Request.form("higher")rs.Open "SELECT * FROM Books WHERE Price BETWEEN '%" & highstring & "%' AND '%" & lowstring & "%' ORDER BY BookTitle",conn%> Any help much appreciatedCheersCM <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
dhsd6061 Posted January 5, 2006 Share Posted January 5, 2006 I agree with asko1981. Use something like this:rs.Open "SELECT * FROM Books WHERE Price < " & highstring & " AND Price > " & lowstring & " ORDER BY BookTitle", conn%>What kind of results are you getting with the other statement? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now