日期:2014-05-16  浏览次数:20995 次

分页跳转传值失败
错误提示:
错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'type='' and checkstate=' 中。
/admin/vip_show.asp, 第 28 行

28行代码:rs.open sql,conn,1,1


一开始以为是sql语句错误,打印出来放到access数据库中查询,可以查到值;
后来发现sql语句是做了判断的,在分页代码跳转时应该在把条件在传一次,但是还是提示错误,
后来做删除信息链接的时候,也是这个错误,现在看来应该不是分页代码跳转这块的问题,现在纠结了,看不到错误的地方


<!--#include file="../Data/conn.asp" -->
<!--#include file="../Include/function.asp"-->
<%
response.charset = "GBK"
if session("Admin") = "" then
call ShowMsg("非法登录","admin_login.asp")
end if


dim rs,sql,title,state1,type1

state1=request.form("payfor") '获取管理员选择的付费状态(0、1、all)
type1=request.form("select") '获取管理员选择的信息类别
if(type1="") then '如果类型为空
state1=request.form("state1") '获取付费状态
type1=request.form("type1") '获取付费类型
end if

set rs = server.createobject("adodb.recordset")

if(state1="all") then  '付费状态为“全部”,则查询指定信息类别下的所有付费信息,并按id降序排列
sql="select * from VipInfo  where type='"&type1&"' order by id desc"
else '付费状态为“已付费”或是“为付费”,则按指定的条件进行查询,并按id降序排列
sql="select * from VipInfo  where type='"&type1&"' and checkstate="&state1&" order by id desc"
'response.write sql[select * from VipInfo where type='招聘信息' and checkstate=0 order by id desc]
'response.end
end if
rs.open sql,conn,1,1


'分页模块
dim i,page
rs.pagesize = 5 '设置每页多少条
allpage = rs.pagecount '总页数
allcount = rs.recordcount '总条数
page = request.querystring("page") '接收传过来的page页码

'一开始,进入列表页,没有传page值,那么page就是空置,所以可以设置为第一页1
if page = "" then page = 1

'判断如果不是数字,那么page = 1
if isnumeric(page) then
'如果是0或者负数,那么page还是1 cint是整型,clng是长整形
if clng(page) <1 then page = 1
'如果page大于最大的分页数,那么就是最后一页
if clng(page) > rs.pagecount then page = rs.pagecount
else
page = 1
end if

'当前页码
if not rs.eof then
rs.absolutepage = page
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">