|
|
vforme
发表于 2009-9-12 14:53:17
|
显示全部楼层
还是连不上数据库
conn.asp文件代码:
<!--#include file="config.asp"-->
<!--#include file="Inc/function.asp"-->
<%
Dim YlmvPath
Dim SystemDatabaseType
Dim db, SqlDatabaseName, SqlPassword, SqlUsername, SqlHostIP,UserTrueIP,ConnStr,conn
YlmvPath = request.servervariables("path_info")
YlmvPath = left(YlmvPath,instrrev(YlmvPath, "/"))'获取安装目录
UserTrueIP=Replace(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),"'","")
If UserTrueIP="" or isnull(UserTrueIP) Then UserTrueIP=Replace(Request.ServerVariables ("REMOTE_ADDR"),"'","")
function valid_ip(guest_ip)
valid_ip=true
dim ti,tdim,hn,aabb,ccdd
hn=guest_ip
tdim=split(bad_ip,"|")
aabb=split(hn,".")
for ti=0 to ubound(tdim)
ccdd=split(tdim(ti),".")
if ccdd(3)="*" then
if ccdd(2)="*" and ccdd(3)="*" then
if ccdd(1)="*" and ccdd(2)="*" and ccdd(3)="*" then
hn=aabb(0)&".*.*.*"
if instr(hn,tdim(ti))>0 then valid_ip=false:erase tdim:exit function
else
hn=aabb(0)&"."&aabb(1)&".*.*"
if instr(hn,tdim(ti))>0 then valid_ip=false:erase tdim:exit function
end if
else
hn=aabb(0)&"."&aabb(1)&"."&aabb(2)&".*"
if instr(hn,tdim(ti))>0 then valid_ip=false:erase tdim:exit function
end if
else
hn=aabb(0)&"."&aabb(1)&"."&aabb(2)&"."&aabb(3)
if instr(hn,tdim(ti))>0 then valid_ip=false:erase tdim:exit function
end if
next
erase tdim
end function
on error resume next
'数据库链接字段请不需要修改------------------------------------------------------------------------------
If SystemDatabaseType = "SQL" Then
ConnStr = " rovider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlHostIP & ";"
Else
ConnStr = " rovider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
End If
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查Config.asp文件中的数据库参数设置。"
Response.End
End If
'数据库关闭--------------------------------------------------------------------------------------
Sub CloseConn()
On Error Resume Next
If IsObject(Conn) Then
Conn.Close
Set Conn = Nothing
End If
End Sub
%>
config.asp 代码:
<%
Const InstallDir = "/0001" '网站目录,务必认真填写,放在根目录的话就填“/”
SystemDatabaseType= "ACCESS" 'ACCESS为ACCESS数据库,SQL为SQL数据库
db = InstallDir & "Data/xxxx.asa" '主数据库名称和路径
SqlHostIP = "(local)" 'SQL数据库IP
SqlDatabaseName = "" 'SQL数据库名
SqlUsername = "" 'SQL数据库用户名
SqlPassword = "" 'SQL数据库用户密码
%>
结果显示:数据库连接出错,请检查Config.asp文件中的数据库参数设置。 |
|