Conn.execute(SQL)(0),运行多次后提示:SQL Server 不存在或拒绝访问
来源:百度知道 编辑:UC知道 时间:2024/06/08 05:38:12
在ASP中,下面的查询运行多次后(有时候几十次,有时几百次)就出错,提示:
Microsoft OLE DB Provider for SQL Server 错误 '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。
SelectClass.asp,行 39
39行如下:
LogText = Conn.execute("SELECT LogText FROM TLog where ID = "&ID)(0)
开始查询是正常的,连续运行多次后就出错,是不是每次的查询要关闭掉,Conn.execute(SQL)(0)这种写法要如何关闭?
Conn.Close
Set Conn=Nothing
数据连接用完后后有关闭。
Rs.Open SQL,Conn,1,1
这个Rs集也有关闭。
Rs.Close
Set Rs=Nothing
就是下面这行的写法不知道要不要关闭?
LogText = Conn.execute("SELECT LogText FROM TLog where ID = "&ID)(0)
Microsoft OLE DB Provider for SQL Server 错误 '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。
SelectClass.asp,行 39
39行如下:
LogText = Conn.execute("SELECT LogText FROM TLog where ID = "&ID)(0)
开始查询是正常的,连续运行多次后就出错,是不是每次的查询要关闭掉,Conn.execute(SQL)(0)这种写法要如何关闭?
Conn.Close
Set Conn=Nothing
数据连接用完后后有关闭。
Rs.Open SQL,Conn,1,1
这个Rs集也有关闭。
Rs.Close
Set Rs=Nothing
就是下面这行的写法不知道要不要关闭?
LogText = Conn.execute("SELECT LogText FROM TLog where ID = "&ID)(0)
记得要
用完 Rs后 Rs.Close
Set Rs = Nothing
用完 Conn后 关闭 Conn.Close
Set Conn = Nothing
老连 服务器 会生气的, 吃着嘴里的,看着碗里 不好的!没规矩
--------------------
LogText = Conn.execute("SELECT LogText FROM TLog where ID = "&ID)(0)
参考:
conn.execute("select id,title,content from document where id=1")(0) 取id
conn.execute("select id,title,content from document where id=1")(1) 取title
conn.execute("select id,title,content from document where id=1")(2) 取content
Top
conn.execute(sql)(0)
相当于
set rs = conn.execute(sql)
t = rs(0)
只是直接返回给LogText了,你可试试
set rs = conn.execute(sql)
t = rs(0) 模式看看出错不?