Isa*_*aac 8 variables ssis dts
我遇到了一个持续的错误:
在集合中找不到该元素.
当您尝试在执行包期间从容器上的集合中检索元素并且该元素不存在时,会发生此错误.
我已经在我的脚本任务中的只读和读写变量中检查,双重和三重检查了我的变量列表.我把它调试到死,并从另一个程序员那里获得了输入,他们也无法发现问题.我也研究过没有尽头.
脚本任务代码:
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
Run Code Online (Sandbox Code Playgroud)
小智 13
对于其他正在努力解决这个问题的人来说,我的解决方案如下:(注意我User::在脚本任务中获取变量值时不使用)
您需要设置新添加的变量,如下所示:
希望这可以帮助
我只是遇到了同样的问题,并且无法找到问题了很长时间。我发现该错误的原因是我错过了“用户”和变量名之间的冒号之一。
我有这个(导致错误):
string FileName = UserVariables["User:CurrentFileName"].Value.ToString();
当我应该有这个:
string FileName = UserVariables["User::CurrentFileName"].Value.ToString();
万一其他人有同样的问题:)
噢……男人。令人惊奇的是,你可以盯着这些东西看几个小时,却错过了一些愚蠢的事情。
列表中缺少 strFooter。
现在一切就绪。衷心感谢那些看过和评论的人。Eric,谢谢,我会记住,因为有时我可能需要使用 C 而不是 VB(还没有,但会)。