asp按条件查询数据库和输出查询结果

2024-12-04 16:38:04
推荐回答(3个)
回答1:


<%
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select top 20 * from test where username like '%kiming%' order by id desc"
rs.Open sql,conn,1,3
Response.ContentType = "text/xml"
Response.Expires = -1
Response.Write("")
Response.Write("")
Response.Write("")
do while not rs.eof
Response.Write("")
rs.movenext
loop
Response.Write("
")
Response.Write("
")
if Conn.state<>0 then Conn.close
set Conn=nothing
if rs.state<>0 then rs.close
Set rs = Nothing
%>

回答2:

sql="select top 20 * from test where message like '%kiming%' order by id desc"

回答3:

sql="select top 20 * from test"