一段asp连接数据库的代码,请大虾帮忙看看哪里出错了,总是提示数据库连接出错
Response.Buffer=TrueDimdbPathDimdbSrvPathDimconnDimconnSrvDimstrAdminPasswordstrAdmin...
Response.Buffer = True
Dim dbPath
Dim dbSrvPath
Dim conn
Dim connSrv
Dim strAdminPassword
strAdminPassword = "123456" '系统登录密码,可自行修改
dbPath = "Datamdb\PTData.asp" '可以自己修改数据库存放路径和文件名
Sub ConnectionDatabase
Dim ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(dbPath)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
Err.clear
Set conn = NoThing
Response.Write "数据库连接出错!"
Response.End
End If
End Sub 展开
Dim dbPath
Dim dbSrvPath
Dim conn
Dim connSrv
Dim strAdminPassword
strAdminPassword = "123456" '系统登录密码,可自行修改
dbPath = "Datamdb\PTData.asp" '可以自己修改数据库存放路径和文件名
Sub ConnectionDatabase
Dim ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(dbPath)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
Err.clear
Set conn = NoThing
Response.Write "数据库连接出错!"
Response.End
End If
End Sub 展开
2个回答
展开全部
先注释On Error Resume Next看看报什么错
追问
没有错误代码,只有这一段话呀,本人菜鸟,不太懂。请指教
追答
你注释了么?注释了连接不上肯定会报错,试试下面的,看看报什么错误
Response.Buffer = True
Dim dbPath,dbSrvPath,conn,connSrv,strAdminPassword
strAdminPassword = "123456" '系统登录密码,可自行修改
dbPath = "Datamdb/PTData.asp" '可以自己修改数据库存放路径和文件名
Sub ConnectionDatabase
Dim ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(dbPath)
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询