"" then
exec=exec&" and main_id="&main_id
end if
if sub_id"" then
exec=exec&" and sub_id="&sub_id
end if
exec=exec&" order by id desc"
rs.open exec,conn,1,1
if rs.eof then
response.Write "此分类暂无产品!"
else
rs.PageSize =8 '每页记录条数
代码有错误吗,错在哪里
exec是你定义的一个记录变量,把SQL查询语句暂时存放在这个变量中,exec=exec&这是起一个连接作用,就是把exec之前的语句和现在的串联起来!比如你当main_id和sub_id不为空时,完整的语句应该是这样:exec="select * from product where 1=1 and main_id="&main_id&" and sub_id="&sub_id&" order by id desc"至于你说的代码有错误,光从这段语句是是看不出来哪里有问题,你在rs.open exec,conn,1,1这一名之前加response.write exec然后运行一下把产生的SQL语句拷到数据库查询分析器里执行一下看有没有问题