主题:  记录集条件不符合时,该怎么做?

anlyjmy

职务:普通成员
等级:1
金币:1.0
发贴:179
注册:2002/4/17 13:59:48
#12002/7/19 10:24:07
用UD建了记录集后,我输入的查询条件如果不符合时,我想转到一个“没有找到你的记录”页面,我该怎么做?

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_1_STRING
Recordset1.Source = "SELECT * FROM tab WHERE name LIKE '%"&request("textfield")&"%' ORDER BY ID DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>

<%if rs.eof and rs.bof then%>
<%response.redirect "back.htm"%>
<%end if%>
以上三句是我加的,但是有错,我该怎么办?



感觉不错

职务:普通成员
等级:1
金币:0.0
发贴:83
注册:2001/11/29 13:44:53
#22002/7/19 10:51:44
应为:
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_1_STRING
Recordset1.Source = "SELECT * FROM tab WHERE name LIKE '%"&request("textfield")&"%' ORDER BY ID DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
If (Recordset1.EOF) Then
Response.Redirect("back.htm")
End If
%>



感觉不错

职务:普通成员
等级:1
金币:0.0
发贴:83
注册:2001/11/29 13:44:53
#32002/7/19 10:53:43
重发:
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_1_STRING
Recordset1.Source = "SELECT * FROM tab WHERE name LIKE '%"&request("textfield")&"%' ORDER BY ID DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>

<%
If (Recordset1.EOF) Then
Response.Redirect("back.htm")
End If
%>



swordboy

职务:普通成员
等级:1
金币:0.0
发贴:4
注册:2001/1/14 15:48:56
#42002/7/19 23:39:37
anlyjmy在上个帖子中说
引用:
用UD建了记录集后,我输入的查询条件如果不符合时,我想转到一个“没有找到你的记录”页面,我该怎么做?

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_1_STRING
Recordset1.Source = "SELECT * FROM tab WHERE name LIKE '%"&request("textfield")&"%' ORDER BY ID DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>

<%if rs.eof and rs.bof then%>
rs没定义,改为
<%if Recordset1.eof and Recordset1.bof then%>

<%response.redirect "back.htm"%>
<%end if%>
以上三句是你加的,但是只有一句有错,你该这么办。



编辑历史:[这消息被swordboy编辑过(编辑时间2002-07-19 23:41:49)]
[这消息被swordboy编辑过(编辑时间2002-07-19 23:44:04)]