28,391
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private dllServer As Server
Private dllApplication As Application
Private dllSession As Session
Private dllResponse As Response
Private dllRequest As Request
Public dllConn As ADODB.Connection
Public dllRs As ADODB.Recordset
Public Function OnStartPage(myScriptingContext As ScriptingContext)
Set dllServer = myScriptingContext.Server
Set dllApplication = myScriptingContext.Application
Set dllSession = myScriptingContext.Session
Set dllResponse = myScriptingContext.Response
Set dllRequest = myScriptingContext.Request
End Function
Public Function OnEndPage()
Set dllServer = Nothing
Set dllApplication = Nothing
Set dllSession = Nothing
Set dllResponse = Nothing
Set dllRequest = Nothing
End Function
Public Function openConn()
Dim connStr As String
connStr = "driver={sql server};server=127.0.0.1;database=hzt;uid=sa;pwd=1234"
Set dllConn = dllServer.CreateObject("ADODB.Connection")
dllConn.Open connStr
If (Err.Number <> 0) Then
dllResponse.Write ("<font color='#EE0000'>数据库连接出错!</font>")
Err.Clear
dllResponse.End
Else
Set openConn = dllConn
End If
End Function
Dim conn,dllConn
Set conn = Server.CreateObject("ADODB.Connection")
Set dllConn = Server.CreateObject("Web.Conn")
Set conn = dllConn.openConn
Response.Write(conn.ConnectionString)