gpt4 book ai didi

c# - SSIS - 如何使脚本组件失败任务?

转载 作者:行者123 更新时间:2023-12-04 12:59:01 26 4
gpt4 key购买 nike

我有一个脚本组件(脚本转换),我需要能够使 DFT 失败,即它所属的数据流任务。

我正在触发这样的错误

try
{
// Does some work here, which can fail...
}
catch (Exception ex)
{
bool pbCancel = false;
this.ComponentMetaData.FireError(0, Variables.TaskName, "Error message: " + ex.Message, String.Empty, 0, out pbCancel);
}

但是,FireError 不会导致任务失败。

备注 这是数据转换任务中的脚本组件 - 不是脚本任务。

我该怎么做才能使脚本组件中的此任务失败?

最佳答案

在您的示例中,您正在捕获异常但未抛出异常。只需添加

catch (Exception ex)
{
// ... your other code here
throw ex;
}

并且组件将失败。

关于c# - SSIS - 如何使脚本组件失败任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17164661/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com