2
我創建了這個函數,但它似乎給我一個問題。我想將字典存儲到Session變量中,以便我可以訪問整個網站中的字典。我不斷收到錯誤所需對象:DictionaryObject或它會說此密鑰已存在於字典。有人可以告訴我我做錯了什麼嗎?將字典存儲到會話中
我在本文中看過storing dictionary in session,但並沒有真正適合我所要做的!
Function LoadPermissions()
Dim SQLString
SQLString ="SELECT datafields here... FROM " & TBL_employees_permissions & " AS p WHERE p.eid = '" & Clng(12) & "';"
If IsObject(Session("dicPermissions")) = True Then
Set dicPermissions = Session("dicPermissions")
Else
Set dicPermissions = Server.CreateObject("Scripting.Dictionary")
End If
db_conn conn, rs '
Set myRS = conn.Execute (SQLString)
For each item in myRS.Fields
If IsObject(Session("dicPermissions")) = True AND DictionaryObject.Exists(Trim(item.Name)) = False Then
dicPermissions.Add Trim(item.Name), Trim(myRS(item.Name))
End If
Next
db_disconn conn, rs
Set Session("dicPermissions") = dicPermissions 'Store Dictionary to session array.
End Function