germchen在上个帖子中说
引用:
试试这样行不行
id=request("id)
sql="select * from table order by id"
set rs=conn.execute(sql)
if not rs.eof then
idfirst=rs("id")
rs.movelast
idend=rs("id")
if idfirst idd1=id+1
idd2=id-1
sql1="select * from table where id="&idd1
sql2="select * from table where id="&idd2
end if
if id=idfirst then
idd1=id+1
sql1="select * from table where id="&idd1
end if
if id=idend then
idd1=id-1
sql1="select * from table where id='"&idd1
end if
if sql1<>"" then
set rs1=conn.execute(sql1)
end if
if sql2<>"" then
set rs1=conn.execute(sql1)
set rs2=conn.execute(sql2)
end if
.....
end if
很严谨了。
我在BLUEIDEA也看到这篇帖子,那里帖了代码,基本也是这个做法,
但是他要问有没有快点的。
我写3条SQL:
sql1="select * from table where id = "& id
sql2="select top 1 * from table where id < "& id &" order by id DESC"
sql3="select top 1 * from table where id > "& id
可行?