[QUOTE]<%
Response.CharSet = "gb2312"
'================================================================
'系统数据库类型定义
'0: SQL 2000 数据库
'1: Access 数据库
'================================================================
Dim Auto_DataBaseKind
Auto_DataBaseKind = "0"
'================================================================
'过程作用:打开数据库连接
'================================================================
Dim Conn,Auto_DataBaseName,Auto_HostName,Auto_DataBaseUrl
Sub ConnOpen()
On Error Resume Next
Dim Auto_DataBaseName,Auto_HostName,Auto_UserId,Auto_LogoPassWord,Auto_OaClassConnStr,Auto_DataForder,Auto_DataBaseUrl
If Auto_DataBaseKind = "0" Then
Auto_DataBaseName = "DataBase" '数据库名称
Auto_HostName = "127.0.0.1" '服务器名称或IP
Auto_UserId = "sa" '登陆数据库用户ID
Auto_LogoPassWord = "" '登陆数据库密码
Auto_OaClassConnStr = "Provider = Sqloledb; User ID = " & Auto_UserId & "; Password = " & Auto_LogoPassWord & "; Initial Catalog = " & Auto_DataBaseName & "; Data Source = " & Auto_HostName & ";"
ElseIf Auto_DataBaseKind = "1" Then
Auto_DataBaseName = "DataBase.mdb" '数据库名称
Auto_DataForder = "DataBase\" 'Access数据库存放目录,请务必以“\”结尾
Auto_DataBaseUrl = Server.MapPath("\") &"\"& Auto_DataForder & Auto_DataBaseName
Auto_OaClassConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Auto_DataBaseUrl
Else
Response.Write("数据库类型定义错误,请确认文件Option/Conn.Asp中是数据库类型是否正确!")
Response.End()
End If
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open Auto_OaClassConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write ("数据库连接出错,请检查文件Option/Conn.Asp中的数据库连接字符串是否正确!")
Response.End()
End If
End Sub
'================================================================
'过程作用:关闭数据库连接
'================================================================
Sub ConnClose()
Conn.close()
Set Conn = Nothing
End Sub
%>[/QUOTE]