イエナイコト漫画1到3:求asp高手帮忙,我都快挂了。

来源:百度文库 编辑:神马品牌网 时间:2024/05/08 23:28:39
做一个新闻具体内容页提示错误如下:
错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/news/newspop.asp, 第 9 行

newspop.asp具体内容如下

<%
url=request.ServerVariables("HTTP_REFERER")
id=request("id")
if id="" then
response.Write "非法访问!"
response.End()
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from Article where ArticleID="&id,conn,1,1
if rs.eof and rs.bof then
response.Write"查询不到该数据"
response.End()
else
set rs1=server.CreateObject("adodb.recordset")
rs1.open "update Article set hits=hits+1 where ArticleID="&id,conn,3,2
set rs1=nothing
rs1.close
updatetime=rs("updatetime")
datetime1=DateValue(updatetime)
title1=rs("title")
Author1=rs("Author")
Hits1=rs("Hits")
xxx=replace(rs("content"),"../UploadFiles","UploadFiles")
xxx=replace(xxx,"../admin/UploadFiles","UploadFiles")
rs.close
end if
%>

我就是不知道到底是哪个字段出的问题,
还是不行,又是这个语句的错误 rs.open "select * from Article where ArticleID="&id,conn,1,1 我现在不知道的就是他到底和数据库德那里对不上了,真麻烦。

问题出在你虽然用了response.End(),但那只是中止了对客户端的输出,并没有中止服务器端程序的运行,所以下面的代码仍会继续,于是在rs.open那行上因为id="",就会报错了。

解决方法是只有在id<>""时才执行后面的代码,具体如下:

<%
url=request.ServerVariables("HTTP_REFERER")
id=request("id")

if id="" then

response.Write "非法访问!"
response.End()

else

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from Article where ArticleID="&id,conn,1,1
if rs.eof and rs.bof then
response.Write"查询不到该数据"
response.End()
else
set rs1=server.CreateObject("adodb.recordset")
rs1.open "update Article set hits=hits+1 where ArticleID="&id,conn,3,2
set rs1=nothing
rs1.close
updatetime=rs("updatetime")
datetime1=DateValue(updatetime)
title1=rs("title")
Author1=rs("Author")
Hits1=rs("Hits")
xxx=replace(rs("content"),"../UploadFiles","UploadFiles")
xxx=replace(xxx,"../admin/UploadFiles","UploadFiles")
rs.close
end if

end if
%>

明白了吗?

——————————————————————

在rs.open之前加上这条语句:

response.write("select * from Article where ArticleID="&id)

然后运行页面,把输出的select语句拿到查询分析器里运行一下先。

最后鄙视61252219890303的抄袭行为……

报错是第九行就应该是第九行呀!
仔细看看你的数据库核对一下吧!

问题出在你虽然用了response.End(),但那只是中止了对客户端的输出,并没有中止服务器端程序的运行,所以下面的代码仍会继续,于是在rs.open那行上因为id="",就会报错了。

建议把rs.open "select * from Article where ArticleID="&id,conn,1,1
分为两句:同时修改一下SQL语句。
sql="select * from Article where ArticleID='"&id&"'"
rs.open sql,conn,1,1
这样的话,是那里出问题了就比较容易查找了。

还有id=request("id")中建议判断一下是否为数字
id=tirm(request("id"))
if isnumeric(id)=true then
......
数据库有没有正确连接?先检查一下数据库的连接!