conn.asp

来自「是个不错的文件代码,希望大家好好用,」· ASP 代码 · 共 78 行

ASP
78
字号
<!--#include file="config.asp"-->
<!--#include file="Inc/Inc_Functions.asp"-->
<!--#include file="API/Api_Config.asp"-->
<%
'-----------------------------------------
'conn.asp
'数据库参数设置
'-----------------------------------------
'数据库类型:0-Access,1-Sql Server
Const Is_Sqldata=0
'使用外部数据库:0-不使用,1-使用
Const Is_ot_User=0
Dim G_Sql_DelChar,G_Sql_Now,G_Sql_d_Char
Dim G_Sql_y,G_Sql_m,G_Sql_d,G_Sql_h,G_Sql_mi,G_Sql_s
Dim connstr,conn,db
Dim ot_connstr,ot_conn,ot_usertable,ot_username,ot_password,ot_regurl,ot_lostpasswordurl,ot_modIfypass1,ot_modIfypass2

Call SystemState

Sub link_database()
	If Is_Sqldata=0 Then
		'Access数据库连接参数
		'请务必阅读程序附带的数据库安全设置指南
		'此处必须为以根目录开始,最前面必须为/号
		db =    "/blog/data/s#u%n$b&l$og.mdb"
		ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)		
		G_Sql_d_Char="#"
		G_Sql_y="'y'"
		G_Sql_m="'m'"
		G_Sql_d="'d'"
		G_Sql_h="'h'"
		G_Sql_mi="'n'"
		G_Sql_s="'s'"	
		G_Sql_Now="Now()"	
	Else
		'Sql数据库连接参数:连接名(本地用local,外地用IP)$数据库名$用户名$用户密码
		Dim Sql_DBServer,Sql_DBName,Sql_User,Sql_Password
		Sql_DBServer = "(local)"
		Sql_DBName = "oblog31"
		Sql_User = "oblog"
		Sql_Password = "oblog"
		ConnStr = "Provider = Sqloledb; User ID = " & Sql_User & "; Password = " & Sql_Password & "; Initial Catalog = " & Sql_DBName & "; Data Source = " & Sql_DBServer & ";"
		G_Sql_d_Char="'"
		G_Sql_y="y"
		G_Sql_m="m"
		G_Sql_d="d"
		G_Sql_h="h"
		G_Sql_mi="n"
		G_Sql_s="s"
		G_Sql_Now="getdate()"
	End If
	On Error Resume Next
	Set conn = Server.CreateObject("ADODB.Connection")	
	conn.open ConnStr

	'若使用外部数据库表请自行修改下面的变量值
	If Is_ot_User=1 And InStr(LCase(request.ServerVariables("HTTP_REFERER")),"admin_")=0 Then 
		ot_connstr= "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("/bbs/data/dvbbs7.mdb") 'access外部数据库连接字符串
		'ot_connstr = "Provider = Sqloledb; User ID = ***; Password = ***; Initial Catalog = ***; Data Source = ***;" 'sql外部数据库连接字符串
		Set ot_conn = Server.CreateObject("ADODB.Connection")
		ot_conn.open ot_connStr '外部数据库连接
		ot_usertable="dv_user" '用户表名
		ot_username="username" '用户名字段
		ot_password="userpassword" '密码字段
		ot_regurl="../bbs/reg.asp" '注册用户链接
		ot_modIfypass1="../bbs/modIfyadd.asp?t=1" '修改密码连接
		ot_modIfypass2="../bbs/modIfyadd.asp?t=1" '修改密码提示问题连接
		ot_lostpasswordurl="../bbs/lostpass.asp" '找回密码链接
	End If

	If Err Then
		Err.clear
		Set conn = Nothing
		Response.write "数据库连接出错,请检查连接字串。"
		Response.End
	End If
End Sub
%>

⌨️ 快捷键说明

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