
本地测试新云的源码 用的是站长吧ASP调试工具,提示 数据库连接出错,请打开conn.asp文件检查连接字
我不会用IIIS测试~~也没用过别的本地测试软件~就只会用站长吧ASP调试工具~所以请别让我换软件测试谢谢~conn.asp里面的内容如下::::<%@LANGUAGE=...
我不会用IIIS测试~~也没用过别的本地测试软件~ 就只会用站长吧ASP调试工具~所以请别让我换软件测试 谢谢~
conn.asp 里面的内容如下::::
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
Option Explicit
Dim startime,Conn,db,Connstr
Response.Buffer = True
startime = Timer()
'--定义数据库类别,1为SQL数据库,0为Access数据库
Const isSqlDataBase = 0
Dim NowString, NewAsp, MyAppPath
MyAppPath = ""
'-- 是否开启伪静态功能(False=否,True=是)
Const IsURLRewrite = False
'--系统XML版本设置,最低版本 Const MsxmlVersion=""
Const MsxmlVersion = ".3.0"
If IsSqlDataBase = 1 Then
'-----------------------SQL数据库连接参数---------------------------------------
NowString = "GetDate()"
'--SQL数据库连接参数:数据库名(SqlDatabaseName)、用户名(SqlUsername)、用户密码(SqlPassword)
'--连接名(SqlLocalName)(本地用(local),外地用IP)
Const SqlDatabaseName = "newasp"
Const SqlUsername = "sa"
Const SqlPassword = "newasp"
Const SqlLocalName = "(local)"
'-------------------------------------------------------------------------------
Else
'-----------------------ACCESS数据库连接----------------------------------------
NowString = "Now()"
'--ACCESS数据库连接路径;数据库默认在database目录,第一次使用请修改默认数据库名或路径
'--数据库路径可以使用绝对路径
db = "D:/wwwanyong/92yingxiao/tzbdeshujuku/#ttyinyunok.mdb"
'-------------------------------------------------------------------------------
End If
Dim DBPath
'-- 采集数据库连接路径
DBPath = "D:\word/www/92yingxiao/tzbdeshujuku/#Collection.asa"
Sub ConnectionDatabase()
On Error Resume Next
If IsSqlDataBase = 1 Then
Connstr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ChkMapPath(MyAppPath & db)
End If
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connstr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请打开conn.asp文件检查连接字串。"
Response.End
End If
End Sub
Sub CloseConn()
Set Newasp = Nothing
End Sub
'================================================
' 函数名:ChkMapPath
' 作 用:相对路径转换为绝对路径
' 参 数:strPath ----原路径
' 返回值:绝对路径
'================================================
Function ChkMapPath(ByVal strPath)
Dim fullPath
strPath = Replace(Replace(Trim(strPath), "/", "\"), "\\", "\")
If strPath = "" Then strPath = "."
If InStr(strPath,":\") = 0 Then
fullPath = Server.MapPath(strPath)
Else
strPath = Replace(strPath,"..\","")
fullPath = Trim(strPath)
If Right(fullPath, 1) = "\" Then
fullPath = Left(fullPath, Len(fullPath) - 1)
End If
End If
ChkMapPath = fullPath
End Function
%> 展开
conn.asp 里面的内容如下::::
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
Option Explicit
Dim startime,Conn,db,Connstr
Response.Buffer = True
startime = Timer()
'--定义数据库类别,1为SQL数据库,0为Access数据库
Const isSqlDataBase = 0
Dim NowString, NewAsp, MyAppPath
MyAppPath = ""
'-- 是否开启伪静态功能(False=否,True=是)
Const IsURLRewrite = False
'--系统XML版本设置,最低版本 Const MsxmlVersion=""
Const MsxmlVersion = ".3.0"
If IsSqlDataBase = 1 Then
'-----------------------SQL数据库连接参数---------------------------------------
NowString = "GetDate()"
'--SQL数据库连接参数:数据库名(SqlDatabaseName)、用户名(SqlUsername)、用户密码(SqlPassword)
'--连接名(SqlLocalName)(本地用(local),外地用IP)
Const SqlDatabaseName = "newasp"
Const SqlUsername = "sa"
Const SqlPassword = "newasp"
Const SqlLocalName = "(local)"
'-------------------------------------------------------------------------------
Else
'-----------------------ACCESS数据库连接----------------------------------------
NowString = "Now()"
'--ACCESS数据库连接路径;数据库默认在database目录,第一次使用请修改默认数据库名或路径
'--数据库路径可以使用绝对路径
db = "D:/wwwanyong/92yingxiao/tzbdeshujuku/#ttyinyunok.mdb"
'-------------------------------------------------------------------------------
End If
Dim DBPath
'-- 采集数据库连接路径
DBPath = "D:\word/www/92yingxiao/tzbdeshujuku/#Collection.asa"
Sub ConnectionDatabase()
On Error Resume Next
If IsSqlDataBase = 1 Then
Connstr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ChkMapPath(MyAppPath & db)
End If
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connstr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请打开conn.asp文件检查连接字串。"
Response.End
End If
End Sub
Sub CloseConn()
Set Newasp = Nothing
End Sub
'================================================
' 函数名:ChkMapPath
' 作 用:相对路径转换为绝对路径
' 参 数:strPath ----原路径
' 返回值:绝对路径
'================================================
Function ChkMapPath(ByVal strPath)
Dim fullPath
strPath = Replace(Replace(Trim(strPath), "/", "\"), "\\", "\")
If strPath = "" Then strPath = "."
If InStr(strPath,":\") = 0 Then
fullPath = Server.MapPath(strPath)
Else
strPath = Replace(strPath,"..\","")
fullPath = Trim(strPath)
If Right(fullPath, 1) = "\" Then
fullPath = Left(fullPath, Len(fullPath) - 1)
End If
End If
ChkMapPath = fullPath
End Function
%> 展开
2个回答
展开全部
问题的关键在这里
response.write IsSqlDataBase//你这样输出一下数据看看是不是输出1,如果输出1那么你的数据库是mssql数据库,否则是access数据库,然后根据你的具体状况作相应设置就好了.
If IsSqlDataBase = 1 Then
'-----------------------SQL数据库连接参数---------------------------------------
NowString = "GetDate()"
'--SQL数据库连接参数:数据库名(SqlDatabaseName)、用户名(SqlUsername)、用户密码(SqlPassword)
'--连接名(SqlLocalName)(本地用(local),外地用IP)
Const SqlDatabaseName = "newasp"
Const SqlUsername = "sa"
Const SqlPassword = "newasp"
Const SqlLocalName = "(local)"
'-------------------------------------------------------------------------------
Else
'-----------------------ACCESS数据库连接----------------------------------------
NowString = "Now()"
'--ACCESS数据库连接路径;数据库默认在database目录,第一次使用请修改默认数据库名或路径
'--数据库路径可以使用绝对路径
db = "D:/wwwanyong/92yingxiao/tzbdeshujuku/#ttyinyunok.mdb"
'-------------------------------------------------------------------------------
End If
response.write IsSqlDataBase//你这样输出一下数据看看是不是输出1,如果输出1那么你的数据库是mssql数据库,否则是access数据库,然后根据你的具体状况作相应设置就好了.
If IsSqlDataBase = 1 Then
'-----------------------SQL数据库连接参数---------------------------------------
NowString = "GetDate()"
'--SQL数据库连接参数:数据库名(SqlDatabaseName)、用户名(SqlUsername)、用户密码(SqlPassword)
'--连接名(SqlLocalName)(本地用(local),外地用IP)
Const SqlDatabaseName = "newasp"
Const SqlUsername = "sa"
Const SqlPassword = "newasp"
Const SqlLocalName = "(local)"
'-------------------------------------------------------------------------------
Else
'-----------------------ACCESS数据库连接----------------------------------------
NowString = "Now()"
'--ACCESS数据库连接路径;数据库默认在database目录,第一次使用请修改默认数据库名或路径
'--数据库路径可以使用绝对路径
db = "D:/wwwanyong/92yingxiao/tzbdeshujuku/#ttyinyunok.mdb"
'-------------------------------------------------------------------------------
End If
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询