测试ASP网页出现:数据库连接出错[代码:01],请检查数据库链接文件中的连接字串。
网站欢迎页是HTM的,可以正常访问,而跳转到首页ASP网页的时候出现了“数据库连接出错[代码:01],请检查数据库链接文件中的连接字串。”,这个网站没有任何问题,因为这个...
网站欢迎页是HTM的,可以正常访问,而跳转到首页ASP网页的时候出现了“数据库连接出错[代码:01],请检查数据库链接文件中的连接字串。”,这个网站没有任何问题,因为这个网站一直在服务器上使用着的,服务器系统装的是WIN2003,我的电脑装的是WIN XP SP3,IIS也装好了。请高手指点一下,谢谢。
展开
3个回答
展开全部
<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
dim conn
dim connstr
dim db
db="include/#oyaya!news.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
%>
SQL
set conn=server.CreateObject("adodb.connection")
Dim Conn,ConnStr,Rs,SqlDatabaseName,SqlUsername,SqlPassword ,SqlLocalName,SqlProvider
SqlDatabaseName = "goshi" 'SQL数据库名
SqlUsername = "sa" 'SQL数据库用户名
SqlPassword = "200" 'SQL数据库用户密码
SqlLocalName = "127.0.0.1" 'SQL主机IP地址(本地可用“127.0.0.1”或“(local)”,非本机请用真实IP)
SqlProvider = "SQLOLEDB"
ConnStr = "Provider = "&SqlProvider&"; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Call OpenConn()
Set Rs = Server.CreateObject("Adodb.RecordSet")
Private Sub CloseConn()
Conn.Close
Set Conn = Nothing
End Sub
Private Sub OpenConn()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
End Sub
if err then
err.clear
set conn = nothing
response.write "数据库连接失败!"
response.end
end if
<%
option explicit
response.buffer=true
dim conn
dim connstr
dim db
db="include/#oyaya!news.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
%>
SQL
set conn=server.CreateObject("adodb.connection")
Dim Conn,ConnStr,Rs,SqlDatabaseName,SqlUsername,SqlPassword ,SqlLocalName,SqlProvider
SqlDatabaseName = "goshi" 'SQL数据库名
SqlUsername = "sa" 'SQL数据库用户名
SqlPassword = "200" 'SQL数据库用户密码
SqlLocalName = "127.0.0.1" 'SQL主机IP地址(本地可用“127.0.0.1”或“(local)”,非本机请用真实IP)
SqlProvider = "SQLOLEDB"
ConnStr = "Provider = "&SqlProvider&"; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Call OpenConn()
Set Rs = Server.CreateObject("Adodb.RecordSet")
Private Sub CloseConn()
Conn.Close
Set Conn = Nothing
End Sub
Private Sub OpenConn()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
End Sub
if err then
err.clear
set conn = nothing
response.write "数据库连接失败!"
response.end
end if
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询