asp檔案原始碼:
Set ConnDll = Server.CreateObject("Config.SqlConnection")
Conndll.Db = "yeekang"
Conndll.uid = "sa"
Conndll.pwd = "123456"
ConnDll.ConnectionData()
Set Rs = Server.CreateObject("Adodb.RecordSet")
Sql = "Select * From Ask"
Rs.Open Sql,ConnDll.Conn,1,1
Response.Write(Rs.RecordCount)
config.dll原始碼
Dim ConnStr As String
Public Conn As New ADODB.Connection
Dim rp As Response
Dim rq As Request
Dim ap As Application
Dim se As Session
Dim sr As Server
Public Db As String
Public uid As String
Public Pwd As String
Public Sub OnStartPage(Mysc As ScriptingContext)
Set rp = Mysc.Response
Set rq = Mysc.Request
Set ap = Mysc.Application
Set se = Mysc.Session
Set sr = Mysc.Server
End Sub
Public Sub OnEndPage()
Set rp = Nothing
Set rq = Nothing
Set ap = Nothing
Set se = Nothing
Set sr = Nothing
Public Sub ConnectionData()
ConnStr = "driver={Sql server};server=.;database=" + Db + ";uid=" + uid + ";pwd=" + Pwd
Conn.Open ConnStr
rp.Write (ConnStr)
Public Sub CloseConn()
Conn.Close
asp檔案原始碼:
Set ConnDll = Server.CreateObject("Config.SqlConnection")
Conndll.Db = "yeekang"
Conndll.uid = "sa"
Conndll.pwd = "123456"
ConnDll.ConnectionData()
Set Rs = Server.CreateObject("Adodb.RecordSet")
Sql = "Select * From Ask"
Rs.Open Sql,ConnDll.Conn,1,1
Response.Write(Rs.RecordCount)
config.dll原始碼
Dim ConnStr As String
Public Conn As New ADODB.Connection
Dim rp As Response
Dim rq As Request
Dim ap As Application
Dim se As Session
Dim sr As Server
Public Db As String
Public uid As String
Public Pwd As String
Public Sub OnStartPage(Mysc As ScriptingContext)
Set rp = Mysc.Response
Set rq = Mysc.Request
Set ap = Mysc.Application
Set se = Mysc.Session
Set sr = Mysc.Server
End Sub
Public Sub OnEndPage()
Set rp = Nothing
Set rq = Nothing
Set ap = Nothing
Set se = Nothing
Set sr = Nothing
End Sub
Public Sub ConnectionData()
ConnStr = "driver={Sql server};server=.;database=" + Db + ";uid=" + uid + ";pwd=" + Pwd
Conn.Open ConnStr
rp.Write (ConnStr)
End Sub
Public Sub CloseConn()
Conn.Close
End Sub