ADODB.Recordset 错误 '800a0e7d' 连接无法用于执行此操作。在此上下文中它可能已被关闭或无效。 /Conn.asp,行 71

alanbabby 2014-10-22 09:47:53
ADODB.Recordset 错误 '800a0e7d'

连接无法用于执行此操作。在此上下文中它可能已被关闭或无效。

/Conn.asp,行 71
代码:红色为错误

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%

'--------------------------------------------------
'--------------------------------------------------
Session.CodePage=65001
Response.codepage=65001
Response.Charset="UTF-8"
'on Error Resume Next
Response.Buffer = True
Response.expiresabsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","no-store"

'Response.Clear
'Server.ScriptTimeOut= 999999
'Session.Timeout = 30
'Dim isdata
isdata = 1

Function OpenConn()
dim conn
dim connstr
dim db,pass_word,User_ID,Data_Source
Data_Source="127.0.0.1" '请输入Sqlserver服务器的IP地址,或者数据库实例名称
DbPort="1433" '数据库连接端口号,默认为1433,一般此处不需要更改
db="26" '请输入Sqlserver服务器的数据库名称
User_ID="sa" '请输入连接Sqlserver服务器的用户名
pass_word="sa" '请输入连接Sqlserver服务器的密码

On Error Resume Next
If DbPort="1433" Then
DbPort=""
Else
DbPort=","&DbPort
End If

Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=SQLOLEDB.1;Password='"&pass_word&"';"&"Persist Security Info=True;User ID='"&User_ID&"';"&"Initial Catalog='"&db&"';"&"Data Source='"&Data_Source&DbPort&"';Connect Timeout=15"
conn.Open connstr
Set OpenConn = conn
End Function

if isdata = 1 then
set conn = OpenConn()
else
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Mdb)
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查数据库连接文件中的数据库参数设置。"
Response.End
End If
end if

Sub CloseConn(Conn) '关闭数据库代码
On Error Resume Next
If IsObject(Conn) then
Conn.Close()
Set Conn = Nothing
End If
If Err Then Err.Clear
End Sub

Set RsSet=Server.CreateObject("Adodb.RecordSet")
Sql="Select Top 1 * From Admin Order By ID"
RsSet.Open Sql,Conn,1,1
If RsSet.Eof Then
Response.Write "数据库错误"
Response.end
End If

'网站名称
WebTitle = GetSet(RsSet("SiteName"),"WebName")
'网站子标题
WebsTitle = GetSet(RsSet("SiteName"),"WebsName")
'网站域名
WebUrl = RsSet("SiteUrl")
'网站金币名称
Webjb = RsSet("Webjb")
'网站成长值名称
Webgrow = RsSet("Webgrow")
'系统安全码
SysCode = RsSet("SysKey")
'备案号
beianCode = GetSet(RsSet("SiteFooter"),"footbeian")
'备案号
tongjiCode = GetSet(RsSet("SiteFooter"),"foottongji")
'使用的模板名称
TemplateName=RsSet("TemplateName")
zxwplzb = RsSet("weblzb")
'--------------------------------
'开关
web_on = RsSet("web_on")
JifenOn = RsSet("jifentomoney")
adpagesize = RsSet("syspagesize")
UserManagePath = RsSet("UserManagePath")
'if web_on = 0 then
'response.Redirect("")
'end if
%>
...全文
449 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
alanbabby 2014-10-22
  • 打赏
  • 举报
回复
引用 1 楼 ky_min 的回复:
看不到你出错地方的上下文中有 Conn对象啊~
那要怎么改呢
还在加载中灬 2014-10-22
  • 打赏
  • 举报
回复
看不到你出错地方的上下文中有 Conn对象啊~
还在加载中灬 2014-10-22
  • 打赏
  • 举报
回复
仔细看了下,conn还是有的,CONN它有正常的打开吗 你把这个

If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查数据库连接文件中的数据库参数设置。"
Response.End
End If
也放到OpenConn()的结尾,看看有没有什么内容

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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