错误类型:Microsoft JET Database Engine (0x80040E14)语法错误 (操作符丢失) 在查询表达式 'ispass=1 and isdel=0 and islock=0 and isopen=1 and dept_id=() and dept_num=()' 中.错误代码处dim deptids,deptnumsdeptids =session("dept_i

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 02:04:48
错误类型:Microsoft JET Database Engine (0x80040E14)语法错误 (操作符丢失) 在查询表达式 'ispass=1 and isdel=0 and islock=0 and isopen=1 and dept_id=() and dept_num=()' 中.错误代码处dim deptids,deptnumsdeptids =session(

错误类型:Microsoft JET Database Engine (0x80040E14)语法错误 (操作符丢失) 在查询表达式 'ispass=1 and isdel=0 and islock=0 and isopen=1 and dept_id=() and dept_num=()' 中.错误代码处dim deptids,deptnumsdeptids =session("dept_i
错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'ispass=1 and isdel=0 and islock=0 and isopen=1 and dept_id=() and dept_num=()' 中.
错误代码处
dim deptids,deptnums
deptids =session("dept_id")
deptnums=session("dept_num")
set rs=server.Createobject ("adodb.recordset")
if channelID"" then
sql="select * from news where ("&sql&") and dept_id=("&deptids&") and dept_num=("&deptnums&") and ispass=1 and isdel=0 and islock=0 and isopen=1 order by istop desc,newsid desc"
else
sql="select * from news where ispass=1 and isdel=0 and islock=0 and isopen=1 and dept_id=("&deptids&") and dept_num=("&deptnums&") order by istop desc,newsid desc"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write ""
改成:
sql="select * from news where ispass=1 and isopen=1 and and isdel=0 and islock=0 dept_id in ("&deptids&") and dept_num in ("&deptnums&") order by istop desc,newsid desc"
语法错误 (操作符丢失) 在查询表达式 'ispass=1 and isopen=1 and and isdel=0 and islock=0 dept_id in (2) and dept_num in (1)' 中.
难道语句太长就不行么……

错误类型:Microsoft JET Database Engine (0x80040E14)语法错误 (操作符丢失) 在查询表达式 'ispass=1 and isdel=0 and islock=0 and isopen=1 and dept_id=() and dept_num=()' 中.错误代码处dim deptids,deptnumsdeptids =session("dept_i
1 字符串的查询语句不是打括号,而是打单引号.
应该改成:"dept_id='"& deptids & "'"
如果参数deptids有多个,需要用逗号连接的形式(如:'A','B','C' 注意要单引号,如果不是字符串格式,就直接是A,B,C就可以了),SQL语句需改成"dept_id in ("& deptids & ")"
2 sql="select * from news where ("&sql&") and dept_id=("&deptids&") and dept_num=("&deptnums&") and ispass=1 and isdel=0 and islock=0 and isopen=1 order by istop desc,newsid desc"
这一句中的 ("& sql &")是不是搞错了,和现在这个字符串名字(sql)是一样的.
-----------------------------------------
看样子dept_id 和 dept_num是数字型.
把dept_id=(xxx) 和 dept_num=(xxx)改成
dept_id in (),dept_num in ()
并且需要判断deptids 和 deptnums是否为空,如果为空,就不要加到判断条件里.
另外deptids 和 deptnums 是不是指有多个?如果是多个,需要用逗号分开.