[QUOTE]if len(bookname)<>0 and booktype<>"不清楚" and len(publishing)<>0 then
sql="select * from book where bookname like '%"&bookname&"%' and booktype='"&booktype&"' and publishing like '%"&publishing&"%' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if
if len(bookname)<>0 and booktype<>"不清楚" and len(publishing)=0 then
sql="select * from book where bookname like '%"&bookname&"%' and booktype='"&booktype&"' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if
if len(bookname)<>0 and booktype="不清楚" and len(publishing)<>0 then
sql="select * from book where bookname like '%"&bookname&"%' and publishing like '%"&publishing&"%' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if
if len(bookname)<>0 and booktype="不清楚" and len(publishing)=0 then
sql="select * from book where bookname like '%"&bookname&"%' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if[/QUOTE]
把这段改成下面的试试:
[QUOTE]Dim Condition
Condition = ""
If Len(bookname)<>0 Then
Condition = Condition & " And bookname like '%"& bookname &"%'"
End If
If booktype<>"不清楚" Then
Condition = Condition & " And booktype='"& booktype &"'"
End If
If Len(publishing)<>0 Then
Condition = Condition & " And publishing like '%"& publishing &"%'"
End If
Sql = "select * from book where bookmoney>="& money1 &" and bookmoney<="& money2 & Condition &" order by bookid desc"[/QUOTE]
sql="select * from book where bookname like '%"&bookname&"%' and booktype='"&booktype&"' and publishing like '%"&publishing&"%' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if
if len(bookname)<>0 and booktype<>"不清楚" and len(publishing)=0 then
sql="select * from book where bookname like '%"&bookname&"%' and booktype='"&booktype&"' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if
if len(bookname)<>0 and booktype="不清楚" and len(publishing)<>0 then
sql="select * from book where bookname like '%"&bookname&"%' and publishing like '%"&publishing&"%' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if
if len(bookname)<>0 and booktype="不清楚" and len(publishing)=0 then
sql="select * from book where bookname like '%"&bookname&"%' and bookmoney>="&money1&" and bookmoney<="&money2&" order by bookid desc"
end if[/QUOTE]
把这段改成下面的试试:
[QUOTE]Dim Condition
Condition = ""
If Len(bookname)<>0 Then
Condition = Condition & " And bookname like '%"& bookname &"%'"
End If
If booktype<>"不清楚" Then
Condition = Condition & " And booktype='"& booktype &"'"
End If
If Len(publishing)<>0 Then
Condition = Condition & " And publishing like '%"& publishing &"%'"
End If
Sql = "select * from book where bookmoney>="& money1 &" and bookmoney<="& money2 & Condition &" order by bookid desc"[/QUOTE]
专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)