⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conn.asp

📁 网上购物系统
💻 ASP
字号:
<%
'解决了ACCESS数据库路径的问题!
'采用DBType=0或DBType=1来区分AC库还是MSSQL库
'具体采用AC库时应注意的事项,请看程序说明

DBType=0        '0为Access数据库,1为MSSQL数据库 

'****************ACCESS数据库******************

If(DBType=0) Then

db_path = server.MapPath("/Data/Data.mdb")
Set conn= Server.CreateObject("ADODB.Connection")
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source="&db_path
conn.Open connstr


'*****************MSSQL SERVER数据库******
 
ElseIf(DBType=1) Then

'on error resume next 

'修改以下信息以适合你的网站

DBIP="localhost" '数据库所在地址,如果是本地数据库则为:(local)
DBUserID="sa"  '数据库登陆名
DBPassWord="1"  '数据库密码
DBName="ly_mobi" '数据库名称

connstr = "DRIVER=SQL Server; SERVER="&DBIP&"; UID="&DBUserID&"; password="&DBPassWord&"; DATABASE="&DBName&";CONNect Timeout=300;" 
set conn=server.createobject("ADODB.CONNECTION") 
if err.number<>0 then 
err.clear 
set conn=nothing 
response.write "数据库连接出错!" 
Response.End 
else 
conn.open connstr 
if err then 
err.clear 
set conn=nothing 
response.write "数据库连接出错!" 
Response.End 
end if 
end if 

sub endConnection() 
conn.close 
set conn=nothing 
end sub    
   
'***********************数据库设置错误*****************

Else

   Response.Write"数据库设置错误,请联系管理员!"
   Response.End
End If

'Response.Write StrConn

session.timeout=100

Function GetLocationURL() 
Dim Url 
Dim ServerPort,ServerName,ScriptName,QueryString 
ServerName = Request.ServerVariables("SERVER_NAME") 
ServerPort = Request.ServerVariables("SERVER_PORT") 
ScriptName = Request.ServerVariables("SCRIPT_NAME") 
QueryString = Request.ServerVariables("QUERY_STRING") 
Url="http://"&ServerName 
If ServerPort <> "80" Then Url = Url & ":" & ServerPort 
Url=Url&ScriptName 
If QueryString <>"" Then Url=Url&"?"& QueryString 
GetLocationURL=Url 
End Function
%>
<%
Set rs=server.CreateObject("adodb.recordset")
sql="select * from config"
rs.open sql,conn,1,1
webName=rs("webName")
copyright=rs("copyright")
icp=rs("icp")
icp=rs("icp")
lianxi=rs("lianxi")
host=rs("host")
rs.close
set rs=nothing
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -