variables - 在集合中找不到 SSIS 元素(但我已将它们全部列出!)

标签 variables ssis dts

我收到一个持续性错误:

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::)

  • 在包属性中,我没有将变量包含为 ReadOnlyVariables

  • 您需要按如下方式设置新添加的变量:
  • 右键单击包并选择 编辑
  • 在脚本部分单击 只读变量 读写变量 (取决于您希望变量的行为方式)
  • 选中您希望在脚本任务中使用的变量旁边的复选框
  • 点击好的 保存您的更改

  • 希望这可以帮助

    关于variables - 在集合中找不到 SSIS 元素(但我已将它们全部列出!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25751219/

    相关文章:

    c# - 如何在运行时从 .NET 应用程序更改 DTS 包中的连接字符串?

    java - 使用另一个类的变量

    java - 我如何在整个 Activity 中传递实例变量?

    swift - 将一个 swift 变量绑定(bind)到另一个变量

    sql-server - 带有 DateTime2 列的 SSIS 数据流 CSV 到 SQL Server

    sql - 在SSIS中解析非结构化文本文件并读取每一行以获取所需的数据

    sql-server - 有谁知道将 DTS 迁移到 SSIS 的方法吗?

    用于递归查找和转换电影的 Bash 脚本

    variables - "Handler class should be static or leaks might occur"- 处理程序引用了主要 Activity 变量

    database - SSIS - 源错误输出(没有行将被发送到错误输出......)