asp默认显示最新添加的数据
来源:百度知道 编辑:UC知道 时间:2024/06/01 03:30:59
怎么样让ASP默认显示最新添加的数据呢
我是根据ID来取数据的,但是我想在ID为空的情况下,默认显示最新添加的数据
那位大侠帮帮忙
源代码如下:
<%
if id="" then
????????????? 主要是这里
sql="select * from myfc where id="&id
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1, 1
if not rs.eof then
%>
我是根据ID来取数据的,但是我想在ID为空的情况下,默认显示最新添加的数据
那位大侠帮帮忙
源代码如下:
<%
if id="" then
????????????? 主要是这里
sql="select * from myfc where id="&id
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1, 1
if not rs.eof then
%>
应该是这样的
<%
if id="" then
sql = "select top 1 * from myfc order by id desc"
else
sql="select * from myfc where id="&id
end if
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 1, 1
if not rs.eof then
%>
sql="select * from myfc where id="&id &" order by id desc"
select top 5 from *** order by id