以文本方式查看主题

-  ╋艺 镇╋  (http://wdystv.com/bbs/index.asp)
--  ┣◇网站建设&Web语言  (http://wdystv.com/bbs/list.asp?boardid=4)
----  用config.asp文件配置数据库类型问题  (http://wdystv.com/bbs/dispbbs.asp?boardid=4&id=2068)

--  作者:admin
--  发布时间:2010/8/11 15:04:25
--  用config.asp文件配置数据库类型问题
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
Response.Buffer=True
IsSqlDataBase=0 \'定义数据库类别,0为Access数据库,1为SQL数据库
If IsSqlDataBase=0 Then
\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\' Access数据库 \'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'
datapath ="/" \'数据库目录的相对路径
datafile ="#data#.asa" \'数据库的文件名
c&Server.MapPath(""&datapath&""&datafile&"")
\'C&server.mappath(""&datapath&""&datafile&"")&";DRIVER={Microsoft Access Driver (*.mdb)};"
SqlNowString="Now()"
SqlChar="\'"
ver="1.0"
\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'
Else
\'\'\'\'\'\'\'\'\'\'\' SQL数据库 \'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'
SqlLocalName ="(local)" \'连接IP [ 本地用 (local) 外地用IP ]
SqlUsername ="name" \'用户名
SqlPassword ="pass" \'用户密码
SqlDatabaseName="data" \'数据库名
C; Password=" & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source=" & SqlLocalName & ";"
SqlNowString="GetDate()"
ver="1.0 SQL"
\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'
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
On Error GoTo 0
%>