简单的ASP查询ACEESS数据库问题,高手请指教,急

youhuowx 2004-05-06 11:01:31
<!--#include file="conn.asp"-->
<!--#include file="isadmin.asp"-->
<%
id = trim(request("id"))
tel = trim(request("tel"))
teacher = trim(request("teacher"))

if id = "" then
strquery1 = "true"
else
strquery1 = "id='"&id&"'"
end if
if tel = "" then
strquery2 = "true"
else
strquery2 = "tel='"&tel&"'"
end if
if teacher = "" then
strquery3 = "true"
else
strquery3 = "teacher='"&teacher&"'"
end if

sql = "select * from teacher where "&strquery1&" and "&strquery2&" and "&strquery3
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1 浏览器提示出错的行
if rs.recordcount < 1 then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('没有找到符合条件的用户');history.go(-1);</script>"
response.end
else
%>


只是一个简单的查询,查询3个值ID,TEL和TEACHER,其中数据类型ID是自动编号,TEL是数字,TEACHER是文本。
全部留空查询成功,ID和TEL留空,只填TEACHER时成功,但是填写ID和TEL其中任何一个时就会出错,错误类型:Microsoft JET Database Engine (0x80040E07)
标准表达式中数据类型不匹配。
我是新手,请教下高手到底是怎么回事。
...全文
38 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
youhuowx 2004-05-06
  • 打赏
  • 举报
回复
找到了,就是 reidli(风雨飘香) 说的错误,后面的错误是前面修改的没改回来
十分感谢,结帖了
youhuowx 2004-05-06
  • 打赏
  • 举报
回复
也不对啊,去掉单引号后错误变成
Microsoft VBScript 编译器错误 (0x800A0409)
未结束的字符串常量
/adminsearchteacher.asp, line 25, column 84
sql = "select * from teacher where "&strquery1&" and "&strquery2&" and "&strquery3&"
不过确实ID和TEL全是数字,我也感觉问题出在这里,就是改不出来,急啊
youhuowx 2004-05-06
  • 打赏
  • 举报
回复
不行,改了就提示全错了
reidli 2004-05-06
  • 打赏
  • 举报
回复
去掉id='"&id&"',tel='"&tel&"'的单引号试试
id和tel应该都是数字,用不上单引号吧
youhuowx 2004-05-06
  • 打赏
  • 举报
回复
我感觉这段是对的啊,要不怎么搜索teacher的时候是成功的呢?
我先试下看
skyboy0720 2004-05-06
  • 打赏
  • 举报
回复
还有注意字段的类型!
skyboy0720 2004-05-06
  • 打赏
  • 举报
回复
sql = "select * from teacher where "&strquery1&" and "&strquery2&" and "&strquery3

这句错误

sql = "select * from teacher where 字段="&strquery1&" and 字段="&strquery2&" and 字段="&strquery3"

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧