我正在使用Windows Server 2008 R2 64位和IIS 7.5並託管一個經典的asp(32位)網站並在COM服務器上調用COM組件(它也有Windows服務器2008 R2 64位)。但是,獲取錯誤「權限被拒絕」並且錯誤代碼是800A0046。嘗試使用腳本時權限被拒絕錯誤。字典
Set oDictAOGroup = CreateObject("Scripting.Dictionary")
oDictAOGroup.Add "1000", "5"
oUser.fn_Update_AO_Groups(oDictAOGroup)
asp網站服務器使用DCOM與COM服務器通信。在asp網站上,服務器代理是由COM服務器類創建的。
我創建了一個測試函數,並將值傳遞給該函數,然後代碼工作得很好。
oUser.fn_Update_AO_Groups_Test1("1000", "21")
但是當嘗試傳遞Scipting.Dictionary對象時,會引發權限被拒絕錯誤。 我已經搜索了很多,但都是徒勞無益的。
功能的代碼是
Public Function fn_Update_AO_Groups(vntAODict As Variant)
On Error GoTo ErrorHandler
Dim oADOConnect As AMLCONNECT_V2.clsConnect
Dim oADOConn As ADODB.Connection
Dim oADOCmd As ADODB.Command
Dim vntKey As Variant
If Not objContext Is Nothing Then
Set oADOConnect = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
Set oADOCmd = objContext.CreateInstance("ADODB.Command")
Else
Set oADOConnect = New clsConnect
Set oADOCmd = New ADODB.Command
End If
If IsObject(vntAODict) Then
If oADOConnect.OpenADOConnection(oADOConn) Then
With oADOCmd
.CommandText = "Sp_Upd_AOGroups"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("AO_ID", adInteger, adParamInput)
.Parameters.Append .CreateParameter("Email_Group_ID", adInteger, adParamInput)
Set .ActiveConnection = oADOConn
End With
'Execute stored procedure for each item in the dictionary
For Each vntKey In vntAODict.Keys
oADOCmd.Parameters("AO_ID").Value = vntKey
oADOCmd.Parameters("Email_Group_ID").Value = vntAODict(vntKey)
oADOCmd.Execute
Next
End If
End If
TidyUp:
Set oADOConn = Nothing
Set oADOCmd = Nothing
Set oADOConnect = Nothing
Exit Function
ErrorHandler:
Dim ErrHandler As AMLCONNECT_V2.clsConnect
If Not objContext Is Nothing Then
Set ErrHandler = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
Else
Set ErrHandler = New AMLCONNECT_V2.clsConnect
End If
m_sErrorMessage = "Error Number: " + CStr(Err.Number) + "<BR>" + "Description: " + ErrHandler.LogError(Err.Number, Err.Description, "MODULE: AMLADMIN_V2.clsUsers", "FUNCTION:fn_Update_AO_Groups", errError, errVB, errDatabase, "")
If Not ErrHandler Is Nothing Then Set ErrHandler = Nothing
GoTo TidyUp:
End Function
任何一個可以表明這個辦法補救嗎?
功能代碼串接受
Public Function fn_Update_AO_Groups_Test1(strKey As String, strValue As String)
On Error GoTo ErrorHandler
Dim oADOConnect As AMLCONNECT_V2.clsConnect
Dim oADOConn As ADODB.Connection
Dim oADOCmd As ADODB.Command
Dim vntKey As Variant
Dim ErrHandlerTest As AMLCONNECT_V2.clsConnect
If Not objContext Is Nothing Then
Set oADOConnect = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
Set oADOCmd = objContext.CreateInstance("ADODB.Command")
Else
Set oADOConnect = New clsConnect
Set oADOCmd = New ADODB.Command
End If
If oADOConnect.OpenADOConnection(oADOConn) Then
With oADOCmd
.CommandText = "Sp_Upd_AOGroups"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("AO_ID", adInteger, adParamInput)
.Parameters.Append .CreateParameter("Email_Group_ID", adInteger, adParamInput)
Set .ActiveConnection = oADOConn
End With
'Execute stored procedure for each item in the dictionary
oADOCmd.Parameters("AO_ID").Value = strKey
oADOCmd.Parameters("Email_Group_ID").Value = strValue
oADOCmd.Execute
End If
TidyUp:
Set oADOConn = Nothing
Set oADOCmd = Nothing
Set oADOConnect = Nothing
Exit Function
ErrorHandler:
Dim ErrHandler As AMLCONNECT_V2.clsConnect
If Not objContext Is Nothing Then
Set ErrHandler = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
Else
Set ErrHandler = New AMLCONNECT_V2.clsConnect
End If
m_sErrorMessage = "Error Number: " + CStr(Err.Number) + "<BR>" + "Description: " + ErrHandler.LogError(Err.Number, Err.Description, "MODULE: AMLADMIN_V2.clsUsers", "FUNCTION:fn_Update_AO_Groups", errError, errVB, errDatabase, "")
If Not ErrHandler Is Nothing Then Set ErrHandler = Nothing
GoTo TidyUp:
End Function
感謝, Vaibhav的
你知道函數fn_Update_AO_Groups的簽名/聲明嗎?看起來像類型轉換問題。 –
函數的簽名是'Public Function fn_Update_AO_Groups(vntAODict As Variant)' – vaibhav
Variant應該沒問題。你能發佈函數的代碼嗎?也許只是使用'vntAODict'變量的相關行? (通過編輯添加到您的問題) –