Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 在集合中找不到SSIS元素(但我已将它们全部列出!)_Variables_Ssis_Dts - Fatal编程技术网

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

Variables 在集合中找不到SSIS元素(但我已将它们全部列出!),variables,ssis,dts,Variables,Ssis,Dts,我得到一个持续错误: 在集合中找不到该元素。 当您在执行包期间尝试从容器上的集合中检索元素,但该元素不存在时,会发生此错误 我已经在脚本任务的只读和读写变量中检查、双重和三重检查了变量列表。 我把它调试得死去活来,从这里的另一个程序员那里得到了输入,他也不能发现这个问题。 我也一直在研究 有人看到我的代码有什么问题吗 脚本任务代码: Public Sub Main() Dts.Variables("User::strMailBody").Value = "Thank you for

我得到一个持续错误:

在集合中找不到该元素。
当您在执行包期间尝试从容器上的集合中检索元素,但该元素不存在时,会发生此错误

我已经在脚本任务的只读和读写变量中检查、双重和三重检查了变量列表。 我把它调试得死去活来,从这里的另一个程序员那里得到了输入,他也不能发现这个问题。 我也一直在研究

  • 有人看到我的代码有什么问题吗
脚本任务代码:

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

哦……天哪。令人惊讶的是,你可以盯着这些东西,却错过了一些愚蠢的事情,持续数小时

列表中缺少strFooter


一切都准备好了。衷心感谢那些观看和评论的人。Eric,谢谢,我会记得,有时我可能需要使用VB的C insatead(还没有,但会)。

我也遇到了同样的问题,很久都找不到问题。我发现错误的原因是我遗漏了“User”和变量名之间的一个冒号

我有这个(导致错误的):

string FileName=UserVariables[“User:CurrentFileName”].Value.ToString()

当我应该有这个的时候:

string FileName=UserVariables[“User::CurrentFileName”].Value.ToString()


以防万一其他人也有同样的问题:)

也有类似的问题,经过大量调试后,意识到变量命名约定应该是User::varname,而不是User::varname 我想c#很区分大小写


希望这有助于并为您节省大量宝贵的时间:-)

对于其他正在解决此问题的人,我的解决方案如下:(注意,在脚本任务中获取变量值时,我没有使用
用户::

  • 在包属性中,我没有将变量作为只读变量包含
您需要按如下方式设置新添加的变量:

  • 右键单击软件包并选择编辑
  • 在脚本部分,单击只读变量读写变量(取决于您希望变量的行为方式)
  • 选中要在脚本任务中使用的变量旁边的复选框
  • 单击“确定”保存更改

  • 希望这有帮助

    我认为您不需要变量名中的“User::”部分。我们成功地使用了这样的代码来引用变量:Dts.variables(“Tables”).ValueHmm,我一直在使用它,而且我被告知包含它是一种很好的做法。您的脚本创建了ScriptResults枚举,并包含“Success”?您没有显示它。@TabAlleman-我只是在SO帖子中漏掉了它。经过研究,很可能有一种情况仍然不正确,一个变量名已更改,需要重新映射,或者缺少一个映射。括号似乎只在C#中有用。这并不能真正回答用户遇到的任何问题。在代码示例中,用户正确使用了
    user::