标题:这个是什么错误?郁闷了!
只看楼主
jlky
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2007-3-14
 问题点数:0 回复次数:3 
这个是什么错误?郁闷了!

<%
fczh=Request.Form("fczh")
fcdjzh=Request.Form("fcdjzh")
tdzh=request.Form("tdzh")

if fczh = "" or fcdjzh = "" or tdzh="" then
response.Write ("<Script>alert('请填写完整信息');window.location='index.asp';</script>")
response.End()
end if

set rs = server.CreateObject("adodb.recordset")
sql="select * from Tract where fczh='"&fczh&"' and fcdjzh='"&fcdjzh&"' and tdzh='"&tdzh&"'"
rs.open sql,conn,1,1

if tdzh<>trim(rs("tdzh")) and fcdjzh<>trim(rs("fcdjzh")) and fczh<>trim(rs("fczh")) then
response.write ("<Script>alert('无此记录,请重新输入要查询的信息!');window.location='index.asp';</script>")
end if
%>

这样的查询对吗?我这里加上容错语句显示正常,
但是去掉容错语句就会报错:说红色的地方错误!是语法错误吗?

错误类型:
(0x80020009)
发生意外。


语法错误吗?

[此贴子已经被作者于2007-4-30 0:40:54编辑过]

2007-04-30 00:24
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
得分:0 

[QUOTE]应该是没找到记录,但不明白LZ为什么这样写,你本来就是按条件查询的,还要比较做什么

set rs = server.CreateObject("adodb.recordset")
sql="select * from Tract where fczh='"&fczh&"' and fcdjzh='"&fcdjzh&"' and tdzh='"&tdzh&"'"
rs.open sql,conn,1,1
If rs.Eof Then
response.write ("<Script>alert('无此记录,请重新输入要查询的信息!');window.location='index.asp';</script>")
end if[/QUOTE]


专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-04-30 08:28
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
得分:0 

楼上讲的偶赞同.
只是我想问一个问题.
fczh
fcdjzh
tdzh
是不是都是下拉列表的name?

2007-04-30 08:44
jlky
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2007-3-14
得分:0 

<%
fczh=Request.Form("fczh")
fcdjzh=Request.Form("fcdjzh")
tdzh=request.Form("tdzh")

if fczh = "" or fcdjzh = "" or tdzh="" then
response.Write ("<Script>alert('请填写完整信息');window.location='index.asp';</script>")
response.End()
end if

set rs = server.CreateObject("adodb.recordset")
sql="select * from Tract where fczh='"&fczh&"' and fcdjzh='"&fcdjzh&"' and tdzh='"&tdzh&"'"
rs.open sql,conn,1,1

if tdzh<>trim(rs("tdzh")) and fcdjzh<>trim(rs("fcdjzh")) and fczh<>trim(rs("fczh")) then
response.write ("<Script>alert('无此记录,请重新输入要查询的信息!');window.location='index.asp';</script>")
end if
%>


我想的太复杂了,sql语句已经判断了,我只需要
if rs.eof then
response.write ("<Script>alert('无此记录,请重新输入要查询的信息!');window.location='index.asp';</script>")
response.end
end if
这样就解决问题啦,谢谢提醒!

2007-04-30 11:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-136114-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.311075 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved