ASP连接SQL数据库出错

来源:百度知道 编辑:UC知道 时间:2024/09/13 00:02:01
set rsquery1=server.createobject("adodb.recordset")
x=""
if request("D1")<> "--" then
x=x & "年='"&request("D1")&"'"
if request("D2")<> "--" then
x=x & " and 月='"&request("D2")&"'"
if request("D3")<> "--" then
x=x & " and 日='"&request("D3")&"'"
end if
end if
end if
if request("D4")<> "--" then
x=x & " and 队别='"&request("D4")&"'"
end if
if request("D5")<> "--" then
x=x & " and 复查结果='"&request("D5")&"'"
end if
objrs1="select 队别,sum(case when 复查结果='已整改' then ok else 0 end) as 已整改,sum(case when 复查结果='未整改' then ok else 0 end) as 未整改,sum(case when 复查结果

rsquery1.open objrs1,con,1,1
在这句代码"前"加两句
Response.Write objrs1
Response.End

看看打印出来的sql语句是什么? 检查一下sql语句有没有问题

有可能是sql语句错误造成的

连接数据库有问题
数据库连接的代码呢

天拉。我最没耐心看asp的后台代码了,而且还是用vbscript写的。

一般就是connect页面,在那找找原因。