conn.asp
来自「网上购物系统」· ASP 代码 · 共 50 行
ASP
50 行
<%
on error resume next
response.buffer=true '启用缓冲处理
'数据库路径请在此修改
Const DATABASE_PATH="data/#data.mdb"
Dim ShopPath
ShopPath=Server.MapPath("Conn.asp")
ShopPath=Left(ShopPath,Len(ShopPath)-Len("Conn.asp"))
Dim strDbPath
GetReallyDirectory()
strDbPath=ShopPath & DATABASE_PATH
Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDbPath
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查数据库连接文件中的数据库参数设置。"
Response.End
End If
' 得到实际上的真实目录
Function GetReallyDirectory()
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(ShopPath & "\" & DATABASE_PATH) Then
ShopPath=ShopPath
ElseIf fso.FileExists(ShopPath & "\..\" & DATABASE_PATH) Then
ShopPath=ShopPath & "..\"
ElseIf fso.FileExists(ShopPath & "\..\..\" & DATABASE_PATH) Then
ShopPath=ShopPath & "..\..\"
ElseIf fso.FileExists(ShopPath & "\..\..\..\" & DATABASE_PATH) Then
ShopPath=ShopPath & "..\..\..\"
ElseIf fso.FileExists(ShopPath & "\..\..\..\..\" & DATABASE_PATH) Then
ShopPath=ShopPath & "..\..\..\..\"
ElseIf fso.FileExists(ShopPath & "\..\..\..\..\..\" & DATABASE_PATH) Then
ShopPath=ShopPath & "..\..\..\..\..\"
End If
Set fso=Nothing
GetReallyDirectory=True
Err.Clear
End Function
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?