請問各位大大 , 以下是我的 DLL 跟 ASP , 我的問題是當我的 ASP 建立並使用此物件一段時間後(可能是10天或一個月),會造成 DLLHOST 咬死 CPU 資源 , 但有時候是 SQL Server 2000 咬死 CPU . 不知道是否是我的程式哪裡不當使用,麻煩各位救救命 !!
WINDOW 2000 Server SP3
SQL2000 Server SP2
''************** Global.asa ***********
Session("sql") = Server.CreateObject("sql.data")
''************** end ******************
''************** example.asp ***********
當我要查詢時我的用法大概如下
''單純查詢時
session("sql").searchA "slect * from xxx",record,1
if not record.eof then
response.write record("xxx")
end if
record.close
set record=nothing
''不需更新但需較複雜的查詢時使用
session("sql").searchB "slect * from xxx",record,1
if not record.eof then
response.write record("xxx")
end if
record.close
set record=nothing
''需更新時的查詢
session("sql").searchC "slect * from xxx",record,1
if not record.eof then
response.write record("xxx")
end if
record.close
set record=nothing
''單純的指令
session("sql").executesql "delete * from xxx"
''************** end ******************
''************** SQL DLL **************
''************** Start ****************
Public Sub OnStartPage(sc As ScriptingContext)
Set ScriptingContext = sc
Set Session = ScriptingContext.Session()
Set Application = ScriptingContext.Application()
Set Request = ScriptingContext.Request()
Set Response = ScriptingContext.Response()
Set Server = ScriptingContext.Server()
Connect = "DSN=aa;UID=aa;PWD=bb"
UID = "aa"
PWD = "bb"
End Sub
Public Sub SearchA(SQL, TheRecordSet, CommandType)
Set TheRecordSet = CreateObject("ADODB.RecordSet")
TheRecordSet.CursorLocation = 2
TheRecordSet.Open SQL, Connect, 0, 1, CommandType
End Sub
Public Sub SearchB(SQL, TheRecordSet, CommandType)
Set TheRecordSet = CreateObject("ADODB.RecordSet")
TheRecordSet.CursorLocation = 3
TheRecordSet.Open SQL, Connect, 1, 1, CommandType
End Sub
Public Sub SearchC(SQL, TheRecordSet, CommandType)
Set TheRecordSet = CreateObject("ADODB.RecordSet")
TheRecordSet.CursorLocation = 2
TheRecordSet.Open SQL, Connect, 3, 2, CommandType
End Sub
Public Function ExecuteSQL(SQL)
Set TheConnection = CreateObject("ADODB.Connection")
TheConnection.Open Connect, UID, PWD
TheConnection.Execute SQL, Affected, 1
TheConnection.Close
Set TheConnection = Nothing
ExecuteSQL = Affected
End Function
''************** SQL DLL **************
''************** END ******************
WINDOW 2000 Server SP3
SQL2000 Server SP2
''************** Global.asa ***********
Session("sql") = Server.CreateObject("sql.data")
''************** end ******************
''************** example.asp ***********
當我要查詢時我的用法大概如下
''單純查詢時
session("sql").searchA "slect * from xxx",record,1
if not record.eof then
response.write record("xxx")
end if
record.close
set record=nothing
''不需更新但需較複雜的查詢時使用
session("sql").searchB "slect * from xxx",record,1
if not record.eof then
response.write record("xxx")
end if
record.close
set record=nothing
''需更新時的查詢
session("sql").searchC "slect * from xxx",record,1
if not record.eof then
response.write record("xxx")
end if
record.close
set record=nothing
''單純的指令
session("sql").executesql "delete * from xxx"
''************** end ******************
''************** SQL DLL **************
''************** Start ****************
Public Sub OnStartPage(sc As ScriptingContext)
Set ScriptingContext = sc
Set Session = ScriptingContext.Session()
Set Application = ScriptingContext.Application()
Set Request = ScriptingContext.Request()
Set Response = ScriptingContext.Response()
Set Server = ScriptingContext.Server()
Connect = "DSN=aa;UID=aa;PWD=bb"
UID = "aa"
PWD = "bb"
End Sub
Public Sub SearchA(SQL, TheRecordSet, CommandType)
Set TheRecordSet = CreateObject("ADODB.RecordSet")
TheRecordSet.CursorLocation = 2
TheRecordSet.Open SQL, Connect, 0, 1, CommandType
End Sub
Public Sub SearchB(SQL, TheRecordSet, CommandType)
Set TheRecordSet = CreateObject("ADODB.RecordSet")
TheRecordSet.CursorLocation = 3
TheRecordSet.Open SQL, Connect, 1, 1, CommandType
End Sub
Public Sub SearchC(SQL, TheRecordSet, CommandType)
Set TheRecordSet = CreateObject("ADODB.RecordSet")
TheRecordSet.CursorLocation = 2
TheRecordSet.Open SQL, Connect, 3, 2, CommandType
End Sub
Public Function ExecuteSQL(SQL)
Set TheConnection = CreateObject("ADODB.Connection")
TheConnection.Open Connect, UID, PWD
TheConnection.Execute SQL, Affected, 1
TheConnection.Close
Set TheConnection = Nothing
ExecuteSQL = Affected
End Function
''************** SQL DLL **************
''************** END ******************
全站熱搜
留言列表