连接数据库出错

michaelgy 2004-12-08 04:25:25
原文件
<%
hostName = "localhost"
userName = "sa"
password = "sa"
dbName = "SMG"

Dim Params, conn

Params = "driver={SQL Server};server=" & hostName & ";uid=" & userName & _
";pwd=" & password & ";database=" & dbName

Set conn = Server.CreateObject("ADODB.Connection")
conn.Properties("Connect Timeout") = 20000
conn.Open Params


set rs = conn.execute("select Top 1 * from tv")
response.write rs(0)
response.write "------------------"

set rs = conn.execute("select Top 1 * from leavemessage")
response.write rs(0)
conn.close
set conn = nothing
%>

报错:
28G-0001------------------
Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005'

[Microsoft][ODBC SQL Server Driver][DBNETLIB]一般性网络错误。请检查网络文档。

/html2/jiansuo/demo.asp,行21



有谁知道吗? 谢谢 在线等
...全文
92 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
牛奶 2004-12-08
set rs = conn.execute("select Top 1 * from tv")
response.write rs(0)
response.write "------------------"

这里只要加句 rs.close,相当于清除RS缓存

set rs = conn.execute("select Top 1 * from leavemessage")
response.write rs(0)
'这里要加上
rs.close
Set rs = Nothing’此时才完全释放rs资源
回复
Batistuta0614 2004-12-08
http://dev.csdn.net/develop/article/22/22182.shtm
回复
yb2008 2004-12-08
conn.Properties("Connect Timeout") = 200
回复
AppleBBS 2004-12-08
set rs = conn.execute("select Top 1 * from leavemessage")
response.write rs(0)
'建议这里也要加上
Set rs = Nothing

conn.close
set conn = nothing
%>
回复
AppleBBS 2004-12-08
set rs = conn.execute("select Top 1 * from tv")
response.write rs(0)
response.write "------------------"

下面加上

Set rs = Nothing
回复
pq16344 2004-12-08
select * from ....
可以用response.write rs(0)吗?
回复
MonkeyDHua 2004-12-08
set rs = conn.execute("select Top 1 * from tv")
response.write rs(0)
response.write "------------------"

是不是要加个 rs.close
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-12-08 04:25
社区公告
暂无公告