就是說妳SQL語句,跟本沒有查詢出任何數據,可以妳下面就直接用rs("rmid")了。
解決辦法是在查詢數據庫後,先判斷壹下有沒有查詢出結果。
用:not rs.eof
rs.eof 表示空,沒有任何查詢結果。
not rs.eof 表示有結果。
所以用:if not rs.eof then ‘就是說如果查詢結果不為空,那麽再進行下壹步。
<%
if request("checked")<>"" then
id=request("checked")
id=replace(request("checked")," ","")
id=replace(id,"'","")
id=replace(id,"=","")
id=replace(id,"from","")
set rs=server.createobject("adodb.recordset")
conn="DBQ="+server.mappath("../sjk/3sj0sjk.mdb")+";DRIVER={Microsoft Access Driver (*.mdb)}"
sql="select * from word where rmid in (" & Id & ")"
rs.open sql,conn,1,1
if not rs.eof then
%>
<%for i=1 to rs.pagesize%>
<font size="2"><a target="pword" href="pword.asp?checked=<%=rs("rmid")%>"><%=rs("singer")%>-<%=rs("name")%></a></font><br>
<%
rs.movenext
next
end if
%>