代码
传一段 完整的 查询 代码上来看 哈了 …… 谢谢了
[free]<%
response.flush
day1=1
music=request("music")
m_name=request("m_name")
spname=request("spname")
date1=request("date1")
region=request("region")
year1="2008-9-3"
month1="2008-8-25"
if music="" and m_name="" and spname="" and date1="" and region="" then
response.write "输入查询内容"
else
if Trim(Request.QueryString("page"))="" then
sql="Select BellID,SongName,SingerName,Price,AvailabilityDate,SpName,Region,DownloadsNumber,DownloadsDate,YearMonth from DownloadsData where"
if music<>"" then sql=sql&" SongName like '%"&music&"%' AND"
if m_name<>"" then sql=sql&" SingerName like '%"&m_name&"%' AND"
if spname<>"" then sql=sql&" SpName like '%"&spname&"%' AND"
if region<>"" then sql=sql&" Region like '%"®ion&"%' AND"
if date1<>"" then sql=sql&" YearMonth ='"&date1&"-"&day1&"' AND"
If date1="" Then sql=sql&" DownloadsDate<'"&year1&"' and DownloadsDate>'"&month1&"' AND"
if right(sql,5)="WHERE" then sql=left(sql,clng(len(sql))-5) '解决所有参数都为空的情况
if right(sql,3)="AND" then sql=left(sql,clng(len(sql))-3) '去掉参数最后的and
if Other="New" then
sql=sql&" ORDER BY DownloadsNumber DESC"
else
sql=sql&" ORDER BY DownloadsNumber DESC"
'response.write sql
'response.End()
end if
session("sql")=sql
else
sql=session("sql")
end If
'response.write sql
'response.End()
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
Response.Write("<script>alert('没有记录');history.go(-1);</script>")
else
输出内容自己 写
end if
rs.close
set rs=nothing
end if
%>[/free]
[[it] 本帖最后由 lili0610931 于 2008-9-5 15:53 编辑 [/it]]