'过程作用:打开数据库连接
'================================================================
Dim Conn,Auto_DataBaseName,Auto_HostName,Auto_DataBaseUrl
Sub ConnOpen()
If Auto_DataBaseKind = "0" Then
Auto_DataBaseName = "DataBaseName" '数据库名称
Auto_HostName = "localhost" '服务器名称或IP
Auto_UserId = "sa" '登陆数据库用户ID
Auto_LogoPassWord = "" '登陆数据库密码
Auto_OaClassConnStr = "Provider = SqloledbUser ID = " &Auto_UserId &"Password = " &Auto_LogoPassWord &"Initial Catalog = " &Auto_DataBaseName &"Data Source = " &Auto_HostName &""
ElseIf Auto_DataBaseKind = "1" Then
Auto_DataBaseName = "Data.mdb" '数据库名称
Auto_DataForder = "" 'Access数据库存放目录,请务必以“\”结尾
Auto_DataBaseUrl = Server.MapPath(Auto_DataForder &Auto_DataBaseName)
Auto_OaClassConnStr = "Provider = Microsoft.Jet.OLEDB.4.0Data Source = " &Auto_DataBaseUrl
Else
Response.Write("数据库类型定义错误,请检查文件DbConn.asp中数据库类型定义是否正确!")
Response.End()
End If
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open Auto_OaClassConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write ("数据库连接出错,请检查文件Conn.asp中连接字符串。")
Response.End()
End If
End Sub
'================================================================
'过程作用:关闭数据库连接
'================================================================
Sub ConnClose()
Conn.close()
Set Conn = Nothing
End Sub
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)