Я строю словарь сценариев в ASP classic из двух наборов записей, но по какой-то причине почти каждый элемент (около 70), который я пытаюсь добавить в словарь, говорит, что он существует, и в итоге я получаю только 3 элемента, которые такжекогда я пытаюсь пройтись по словарю после его построения, я получаю исключение.
Dim OrdDict
Set OrdDict = Server.CreateObject("Scripting.Dictionary")
OrdinateSQL = "SELECT COLUMN_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'tblDocTypeTopic';"
Set rsTopicOrdinals = Server.CreateObject("ADODB.RecordSet")
rsTopicOrdinals.Open OrdinateSQL, connUTL, adOpenKeyset
If rsTopicOrdinals.EOF = False Then
Do Until rsTopicOrdinals.EOF
'ordinal positions are "1" indexed, but the array we're building is zero, so subtract one
Response.Write rsTopicOrdinals("COLUMN_NAME") & ": "
If OrdDict.Exists(rsTopicOrdinals("COLUMN_NAME")) Then
response.write "EXISTS<BR>"
OrdDict.Item(rsTopicOrdinals("COLUMN_NAME")) = rsTopicOrdinals("ORDINAL_POSITION") - 1
Else
response.write "NEW<BR>"
OrdDict.Add rsTopicOrdinals("COLUMN_NAME"), rsTopicOrdinals("ORDINAL_POSITION") - 1
End If
rsTopicOrdinals.MoveNext
Loop
End If
rsTopicOrdinals.Close
Set rsTopicOrdinals = Nothing
OrdinateSQL = "SELECT COLUMN_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'tblDocTypeSubTopic';"
Set rsSubTopicOrdinals = Server.CreateObject("ADODB.RecordSet")
rsSubTopicOrdinals.Open OrdinateSQL, connUTL, adOpenKeyset
If rsSubTopicOrdinals.EOF = False Then
Do Until rsSubTopicOrdinals.EOF
'ordinal positions are "1" indexed, add the number of columns in tblDocTypeTopic
'use a unique name for DisplayOrder and Disabled as the exist in both tables
Response.Write rsSubTopicOrdinals("COLUMN_NAME") & ": "
Select Case rsSubTopicOrdinals("COLUMN_NAME")
Case "DisplayOrder"
OrdDict.Add "SubTopicDisplayOrder", rsSubTopicOrdinals("ORDINAL_POSITION") + TopicColCount
Case "Disabled"
OrdDict.Add "SubTopicDisabled", rsSubTopicOrdinals("ORDINAL_POSITION") + TopicColCount
Case "DocTypeTopicID"
Case Else
If OrdDict.Exists(rsSubTopicOrdinals("COLUMN_NAME")) Then
response.write "EXISTS<BR>"
OrdDict.Item(rsSubTopicOrdinals("COLUMN_NAME")) = rsSubTopicOrdinals("ORDINAL_POSITION") + TopicColCount
Else
response.write "NEW<BR>"
OrdDict.Add rsSubTopicOrdinals("COLUMN_NAME"), rsSubTopicOrdinals("ORDINAL_POSITION") + TopicColCount
End If
End Select
rsSubTopicOrdinals.MoveNext
Loop
End If
rsSubTopicOrdinals.Close
Set rsSubTopicOrdinals = Nothing
А вот вывод:
DocTypeTopicID: NEW
DocTypeID: EXISTS
TopicTitle: EXISTS
DisplayOrder: EXISTS
TopicTitleFontSize: EXISTS
TopicTitleFontFormat: EXISTS
ShortTopicTitle: EXISTS
Disabled: EXISTS
HideTopicOnPublish: EXISTS
DocTypeSubTopicID: NEW
DocTypeTopicID: SubTopicTitle: EXISTS
DisplayOrder: DataType: EXISTS
SubTopicOptions: EXISTS
DefaultValue: EXISTS
Required: EXISTS
Custom: EXISTS
CustomModule: EXISTS
AllowBringForward: EXISTS
AllowForwarding: EXISTS
AllowForwardingChecked: EXISTS
ResponseFontSize: EXISTS
TitleFontSize: EXISTS
TitleFontFormat: EXISTS
OITitle: EXISTS
OITitleFontSize: EXISTS
OITitleFontFormat: EXISTS
OIFontSize: EXISTS
OIFontFormat: EXISTS
OIResponseTitle: EXISTS
OIResponseTitleFontSize: EXISTS
OIResponseTitleFontFormat: EXISTS
OIResponseFontSize: EXISTS
OIResponseFontFormat: EXISTS
OINoResponseDisplay: EXISTS
OIShowModifiedDate: EXISTS
OIShowChangedFlag: EXISTS
OIChangedFlag: EXISTS
OINoInstructionDisplay: EXISTS
DocTypeGridTemplate: EXISTS
DocTypeGridID: EXISTS
GridColumns: EXISTS
GridRows: EXISTS
GridMaxSize: EXISTS
RollupShowSubTopicTitle: EXISTS
TimeBack: EXISTS
SubTopicInt1: EXISTS
SubTopicInt2: EXISTS
SubTopicInt3: EXISTS
SubTopicBit1: EXISTS
SubTopicBit2: EXISTS
SubTopicBit3: EXISTS
SubTopicText1: EXISTS
SubTopicText2: EXISTS
SubTopicText3: EXISTS
AutoPopulateOmit: EXISTS
GridRowType: EXISTS
Disabled: SubTopicInt4: EXISTS
SubTopicInt5: EXISTS
SubTopicInt6: EXISTS
SubTopicBit4: EXISTS
SubTopicBit5: EXISTS
SubTopicBit6: EXISTS
SubTopicText4: EXISTS
SubTopicText5: EXISTS
SubTopicText6: EXISTS
HideSubTopicOnPublish: EXISTS
GridSortColumn: EXISTS
GridSortColumnOrder: EXISTS
TextEditor: EXISTS
CustomListTypeID: EXISTS
CustomListID: EXISTS
И когда я зацикливаюсь по нему:
OrdKeys = OrdDict.Keys
For i = 0 To OrdDict.Count - 1
Response.Write OrdKeys(i) & ": " & OrdDict.Item(OrdKeys(i))
Next
Я получаю:
error '80020009'
Кто-нибудь может увидеть изъян в моем коде?Должно быть что-то очевидное, что я просто не вижу.