高手指点ASP查询问题!!着急!! 在线等待@@@

来源:百度知道 编辑:UC知道 时间:2024/06/04 05:36:11
<%
shape=request("shape") 'shape代表形状
Carat1=request("Carat1") 'Carat代表重量
Carat2=request("Carat2")
Price1=request("Price1") 'Price代表价格
Price2=request("Price2")
%>
<%
sql="select * from Diamond where ItemName<>''"
if shape>"" then sql=sql&" and shape='"&shape&"'"
if clarity>"" then sql=sql&" and clarity='"&clarity&"'"
if Carat1>"" and Carat2>"" then sql=sql&" and Carat>"&clng(Carat1)&" and Carat<"&clng(Carat2)&""
if Price1>"" and Price2>"" then sql=sql&" and Price>"&clng(Price1)&" and Price<"&clng(Price2)&""

Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%>

sql="select * from Diamond where ItemName<>''"
if shape<>"" then sql=sql&" and shape='"&shape&"'"
if clarity<>"" then sql=sql&" and clarity='"&clarity&"'"
if Carat1<>"" and Carat2<>"" then sql=sql&" and Carat between "&Carat1&" and "&Carat2&""
if Price1<>"" and Price2<>"" then sql=sql&" and Price between "&Price1&" and "&Price2&""

这样试试.

if shape>"" then sql=sql&" and shape='"&shape&"'"
elseif clarity>"" then sql=sql&" and clarity='"&clarity&"'"
elseif Carat1>"" and Carat2>"" then sql=sql&" and Carat>"&clng(Carat1)&" and Carat<"&clng(Carat2)&""
elseif P