クラシックASPアプリケーションでASP_0147エラーが発生しているお客様がいます。私が最初にチェックしているのは、SQL/ADOリソースをタイムリーに閉じて解放していることです。
彼らのコードは次のパターンを持っています:
Function GetXXXXRecordSet()
Set objConn = Server.CreateObject("ADODB.Connection")
With objConn
.CursorLocation = 3 ''adUseServer (default)
.ConnectionString = strConnectionString
.Open
End With
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn
'' Build command object to call SQL stored proc, snipped for brevity
Set objRs = Server.CreateObject("ADODB.RecordSet")
objRs.Open objCmd, ,3,4 '' Cursor=adOpenStatic, Locktype=adLockBatchOptimistic
'' Return Recordset
Set GetXXXXRecordSet = objRs
If Not objCmd Is Nothing Then
objCmd.ActiveConnection = Nothing '' Should this use a Set statement?
Set objCmd = Nothing
End If
If Not ObjRs Is Nothing The Set objRs = Nothing
End Function
ADOコマンドのActiveConnection=Nothingを設定すると、基になるSQL接続が閉じられますか、それとも明示的に閉じる必要がありますか?
また、次の行が必要です。
objCmd.ActiveConnection = Nothing
なれ:
Set objCmd.ActiveConnection = Nothing
奇妙なことに、最初のバージョンはエラーを生成しないので、私は尋ねます。
ADOを見てから久しぶりで、知識が少し錆びています。