ASP连接数据库出错帮忙看看

go18201007 2010-07-09 02:59:52

<%
function News(SortPath)
dim sql,NewsName,NewFlag
dim rs as adodb.recordset
conn=server.mappath("db/Energy.mdb")
set rs = server.createobject("adodb.connection")
sql="select top 7 * from News where NewsTitle='"+"国内动态"+"'order by NewsId desc"
rs.open sql,conn,1,1
''response.end()
if rs.eof then
response.write "暂无相关信息"
else
do while not rs.eof
if now()-rs("NewsTime")<=2 then
NewsName=StrLeft(rs("NewsTitle"&Language),42)
NewFlag=" <font style=""font-size:9px;color:red;""><strong>NEW</strong></font>"
else
NewsName=StrLeft(rs("NewsTitle"&Language),46)
NewFlag=""
end if
response.write "  "&rs("NewsTime")&" | <a href="">"&NewsName&"</a><br/>"
rs.movenext
loop
end if
rs.close
set rs=nothing
end function
%>




错误提示:

错误类型:
Microsoft VBScript 编译器错误 (0x800A0401)
语句未结束
/chenghe999/首页.asp, line 114, column 7
dim rs as adodb.recordset
------^
...全文
62 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzp4881 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 go18201007 的回复:]
dim rs出现下面错误
初学asp求解

错误类型:
ADODB.Connection (0x800A0E78)
对象关闭时,不允许操作。
/chenghe999/首页.asp, 第 120 行
[/Quote]
这个已经是另外的错误了,不是刚才那个
yangcookie 2010-07-09
  • 打赏
  • 举报
回复
rs.close 可以去掉试一下,有时候会出这样的错误
yangcookie 2010-07-09
  • 打赏
  • 举报
回复
去掉dim rs as adodb.recordset

改为
path=server.mappath("db/Energy.mdb")
Set oconn = Server.CreateObject("ADODB.Connection")
oconn.Open path

set rs= Server.CreateObject("Adodb.RecordSet")
go18201007 2010-07-09
  • 打赏
  • 举报
回复

dim rs出现下面错误
初学asp求解

错误类型:
ADODB.Connection (0x800A0E78)
对象关闭时,不允许操作。
/chenghe999/首页.asp, 第 120 行
lzp4881 2010-07-09
  • 打赏
  • 举报
回复
dim rs 就可以了

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧