I'm wondering if anyone can help me. I'm trying to populate a public dictionary from a recordset returned from an sql table.
It all seems to work fine, except one part. I don't know if it's not counting the number of keys in the dictionary correctly, or they aren't being entered correctly but for whatever reason when I try and show the total count, it always comes back with only 1 (supposed to be around 15) and only displays the first row details.
Can anyone help?
Public UserList As New scripting.Dictionary
Dim USList As Range
Dim USArr(0 To 11) As Variant
Set Cmd = New adodb.Command: Set rs = New adodb.Recordset
.CommandTimeout = 30
.ActiveConnection = cn
.CommandText = "CSLL.DLUsers"
Set rs = .Execute
If Not .BOF And Not .EOF Then
While (Not .EOF)
For i = 1 To 11
USArr(i - 1) = rs(i)
If Not .Exists(rs("Alias")) Then
.Add Key:=rs("Alias"), Item:=USArr
IA = UserList.Items
Debug.Print UserList.Count & " Items in the dictionary"
For Each element In IA
For i = 0 To 10
Set Cmd = Nothing: Set rs = Nothing ': Set UserList = Nothing
rs("Alias") in a variable and then use that variable as key.
dim sKey as String With UserList sKey=rs("Alias") If Not .Exists(sKey) Then .Add sKey,USArr End If End With