我收到一个持续性错误:
The element cannot be found in a collection.
This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
我已经在我的脚本任务中的只读和读写变量中检查、双重和三次检查了我的变量列表。
我已经调试到死,并从这里的另一个程序员那里得到了输入,他也无法发现问题。
我也研究无止境。
脚本任务代码:
Public Sub Main()
Dts.Variables("User::strMailBody").Value = "Thank you for submission. For your convenience, we are including the last four of the HICN# and the Name on the application(s) we have received* from you." _
& vbNewLine & vbNewLine & "Here are the following: " & vbNewLine & vbNewLine
Dts.Variables("User::strMailBody").Value = Dts.Variables("User::strMailbody").Value.ToString() & vbNewLine & Dts.Variables("User::strListing").Value.ToString()
Dts.Variables("User::strMailBody").Value = Dts.Variables("User::strMailBody").Value.ToString() & vbNewLine & vbNewLine & Dts.Variables("User::strFooter").Value.ToString()
If Left(Dts.Variables("User::strAgentID").Value, 2) = "TX" Then
Dts.Variables("User::strSubject").Value = "ACME Health Plans Confirmation: Total "
Else
Dts.Variables("User::strSubject").Value = "ACME2 Baptist Health Plans Confirmation: Total "
End If
Dts.Variables("User::strSubject").Value = Dts.Variables("User::strSubject").Value.ToString() & Dts.Variables("User::lngCountAgent").Value.ToString() & " " & "[RESTRICTED: CONFIDENTIAL]"
Dts.Variables("User::DateSent").Value = Now()
Dts.Variables("User::UserSent").Value = "SSIS"
Dts.TaskResult = ScriptResults.Success
End Sub
最佳答案
对于其他在这个问题上苦苦挣扎的人,我的解决方案如下:(请注意,在我的脚本任务中获取变量值时,我没有使用 User::
)
您需要按如下方式设置新添加的变量:
希望这可以帮助
关于variables - 在集合中找不到 SSIS 元素(但我已将它们全部列出!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25751219/