Loading...
  所在位置:论坛首页 -> ┈┋BBSGood专区┋┈ -> 『BBSGood论坛交流』 -> sql的conn.asp这样设置对吗?
发表新的主题 发起新的投票 发起新的交易 发起新的任务 回复话题
 标题:sql的conn.asp这样设置对吗?
 作者:司法呢 发表于 2008-6-15 18:21:20收藏 编辑 删除 楼主  | 上一篇 下一篇
<%
Option Explicit
Response.Buffer = True
Dim StarTime,EndTime,DataNum,Conn,OutConn

'其它相关初始化配置=================================================================================================
Const BBSInfo="BBSGood.Speed" '这里请输入你的系统的名称,注意如果你要在同一系统中运行多个程序,那么这个名称必须与其它系统不同,要不会有冲突,如果你只运行一个程序,此处可不修改
      StarTime = Timer() '初始化开始运行时间
      DataNum=0  '初始化数据库操作次数计算
Const WriteType=0 '生在html文件的组件类型,0为fso方式,1为ado方式 ,对于不支持fso的用户来用,可以尝试使用ado。
Const CharType="gb2312" '字符类型
'===================================================================================================================

Const DataType=1 '论坛数据库类型,0为access,1为sql数据库

If DataType = 1 Then
    '必修改设置二:========================SQL数据库设置============================================================
    'sql数据库连接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、
    '连接名(SqlLocalName)(本地用local,外地用IP)
    Const SqlDatabaseName = "admin"
    Const SqlPassword = "123456"
    Const SqlUsername = "admin"
    Const SqlLocalName = "(local)"
Else
    '必修改设置三:========================access数据库设置=========================================================
    '免费用户第一次使用请修改本处数据库地址并相应修改data目录中数据库名称,如:将bbsgood_speed.mdb修改为bbsgood_speed.asp
    Const Db="/data/admin.mdb" '数据库路径
End IF
'===================================================================================================================

Sub LinkData()
    Dim ConnStr
    If DataType=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 = " & Server.MapPath(db)
    End If
    On Error Resume Next
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open ConnStr
    If Err Then
    err.Clear
    Set Conn = Nothing
    Response.Write "数据库连接出错,请检查连接字串。"
    Response.End
    End If
End Sub


'=========================================外部表整合参数设置开始=======================================================
Const isoutuser=0 '如果此项为0那么用户名,密码不使用外部数据库或表,如果为1,表示整合到其它系统,用户名和密码采用其它系统的表

if isoutuser=1 then '如果使用外部连接表
    Const OutDataType=1 '如果此项为0.那么表示使用access数据库,如果此项为1,那么表示采用mssql数据库
    
    Const User_out="user"  '外部数据库表名
    Const UserName_out="username"  '外部数据库用户表,用户字段
    Const PassWord_out="password"  '外部数据库用户表,密码字段
    
    Const reg_out="http://www.xxx.com/reg.asp"  '外部用户名注册地址
    Const userinfo_out="http://www.xxx.com/edit.asp" '外部密码修改地址
    Const userlogin_out="http://www.xxx.com/login.asp" '外部帐号登陆地址

    If OutDataType = 1 Then
        '必修改设置二:========================SQL数据库设置============================================================
        'sql数据库连接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、
        '连接名(SqlLocalName)(本地用local,外地用IP)
        Const OutSqlDatabaseName = "admin"
        Const OutSqlPassword = "123456"
        Const OutSqlUsername = "admin"
        Const OutSqlLocalName = "(local)"
    Else
        '必修改设置三:========================access数据库设置=========================================================
        '免费用户第一次使用请修改本处数据库地址并相应修改data目录中数据库名称,如:将bbsgood_speed.mdb修改为bbsgood_speed.asp
        Const OutDb="/bbs/data/admin.mdb" '数据库路径
    End IF
end if

'==========================================外部表整合参数设置结束=======================================================

Sub OutLinkData() '连接外部表函数
    Dim ConnStr
    If OutDataType=1 Then
        ConnStr = "Provider = Sqloledb; User ID = " & OutSqlUsername & "; Password = " & OutSqlPassword & "; Initial Catalog = " & OutSqlDatabaseName & "; Data Source = " & OutSqlLocalName & ";"
    Else
    ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(OutDb)
    End If
    On Error Resume Next
    Set OutConn = Server.CreateObject("ADODB.Connection")
    OutConn.open ConnStr
    If Err Then
    err.Clear
    Set OutConn = Nothing
    Response.Write "数据库连接出错,请检查连接字串。"
    Response.End
    End If

End Sub

Sub CloseData()
    if IsObject(conn) then
        conn.Close
        set conn=nothing
    end if
End Sub
%>

                                                                                                    

顶部
 作者:518 发表于 2008-6-15 21:09:44编辑 删除 引用   第2楼 
???
顶部
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项: 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
    首页 | 购买指南 | 商业版本 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0 beta
    咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
    业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com