一段代码在access中能正常使用,在sql中不能使用
<%dimrs,sql,classid,bytype,num,maxif(request.QueryString("classid")<>"")thenclassid=C...
<%
dim rs,sql,classid,bytype,num,max
if(request.QueryString("classid")<>"") then
classid=Cint(request.QueryString("classid"))
else
classid=0
end if
if(request.QueryString("bytype")<>"") then
bytype=Cint(request.QueryString("bytype"))
else
bytype=0
end if
if(request.QueryString("num")<>"") then
num=Cint(request.QueryString("num"))
else
num=10
end if
if(request.QueryString("max")<>"") then
max=Cint(request.QueryString("max"))
else
max=10
end if
sql="select top "&num&" id,title,pagepath from news where checked=true"
if(classid<>0) then
sql=sql&" and classid="&classid
end if
if(bytype<>0) then
if(bytype=1) then
sql=sql&" and top1=1"'头条
elseif(bytype=2) then
sql=sql&" and totop=1"'置顶
elseif(bytype=3) then
sql=sql&" and tohot=1"'热点
elseif(bytype=4) then
sql=sql&" and imgnews=true"'图文
elseif(bytype=5) then
sql=sql&" and recommend=true"'推荐
end if
end if
sql=sql&" order by id desc"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,1
while not rs.eof
response.Write("document.write('<li>·<a href="""&SiteUrl&"/"&rs(2)&""" target=""_blank"">"&left(replace(rs(1),",","\'"),max)&"</a></li>');"&Chr(10))
rs.movenext
wend
rs.close
set rs=nothing
call connclose
%> 展开
dim rs,sql,classid,bytype,num,max
if(request.QueryString("classid")<>"") then
classid=Cint(request.QueryString("classid"))
else
classid=0
end if
if(request.QueryString("bytype")<>"") then
bytype=Cint(request.QueryString("bytype"))
else
bytype=0
end if
if(request.QueryString("num")<>"") then
num=Cint(request.QueryString("num"))
else
num=10
end if
if(request.QueryString("max")<>"") then
max=Cint(request.QueryString("max"))
else
max=10
end if
sql="select top "&num&" id,title,pagepath from news where checked=true"
if(classid<>0) then
sql=sql&" and classid="&classid
end if
if(bytype<>0) then
if(bytype=1) then
sql=sql&" and top1=1"'头条
elseif(bytype=2) then
sql=sql&" and totop=1"'置顶
elseif(bytype=3) then
sql=sql&" and tohot=1"'热点
elseif(bytype=4) then
sql=sql&" and imgnews=true"'图文
elseif(bytype=5) then
sql=sql&" and recommend=true"'推荐
end if
end if
sql=sql&" order by id desc"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,1
while not rs.eof
response.Write("document.write('<li>·<a href="""&SiteUrl&"/"&rs(2)&""" target=""_blank"">"&left(replace(rs(1),",","\'"),max)&"</a></li>');"&Chr(10))
rs.movenext
wend
rs.close
set rs=nothing
call connclose
%> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询