<!-- METADATA
TYPE="typelib"
FILE="C:Program FilesCommon FilesSystemADOmsado20.tlb"
-->
vbscript CodePage=936%>
Option Explicit
'=========================================================
'容错机制代码
'=========================================================
DIM NDEbug_MSG
NDEBUG_MSG=FALSE 'TRUE,FALSE
IF NDEBUG_MSG = TRUE THEN
'出错过滤
ON ERROR RESUME NEXT
END IF
'=========================================================
'变量声明及定义区
'=========================================================
Dim ConnStr,oConn 'ADO连接变量
Dim sErrmsg '错误变量
'=========================================================
' 事务定义区
'=========================================================
'=========================================================
'Func,Proc定义区
'=========================================================
'=========================================================
' 功能:打开数据源
' 参数:
' 返回值:
'=========================================================
Sub ConnectionDatabase
'sql数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
SqlDatabaseName="xiaods"
SqlPassword="!QAZXSW@"
SqlUsername="xiaods"
SqlLocalName="192.168.211.7"
ConnStr = "Provider=Sqloledb; User ID=" & SqlUsername & "; Password=" & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data source=" & SqlLocalName & ";"
'on error resume next
Set oConn = Server.Createobject("ADODB.Connection")
oConn.open ConnStr
If Err Then
err.Clear
Set oConn = Nothing
sErrmsg= "数据库连接出错,请检查连接字串。"
mError(sErrmsg)
End If
End Sub
'=========================================================
' 功能:关闭数据源
' 参数:
' 返回值:
'=========================================================
Sub CloseDatabase
oConn.close
Set oConn = Nothing
End Sub
'=========================================================
' 功能:输出错误信息
' 参数:sErrmsg
' 返回值:
'=========================================================
sub mError(sErrmsg)
'Response.Write sErrmsg&"please contact system administrator."
response.write " " & vbCrLf
response.write "
response.write " 亚联游戏后台管理 系统" & vbCrLf
response.write " microsoft Visual Studio 6.0"">" & vbCrLf
response.write "" & vbCrLf
response.write " " & vbCrLf
response.write "" & vbCrLf
response.write " " & vbCrLf
response.write "
" & vbCrLf response.write "" & vbCrLf response.write "
response.write "
response.write "" & vbCrLf response.write " |
response.write " " & vbCrLf
response.write " "
end sub
'ConnectionDatabase 'open Datesrc
%>
此为修改版
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752019/viewspace-962626/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10752019/viewspace-962626/