[英]ssis package execution succeeds directly but fails via c# code
I have the following code which seems to works OK for executing an SSIS package from c# BUT every time the variable "Resp" returns a Failure even if the package passes when I execute it directly in SSIS.我有以下代码,它似乎可以从 c# 执行 SSIS 包,但是每次变量“Resp”返回失败时,即使我直接在 SSIS 中执行它时包通过了。
Again, the package contains a Script component that writes to an SQL server table.同样,该包包含一个写入 SQL 服务器表的脚本组件。 All that works OK when the package is executed directly in SSIS but nothing happens when the same package is called via C# with the code below.当包直接在 SSIS 中执行时,一切正常,但当使用下面的代码通过 C# 调用同一个包时,没有任何反应。 I cant work out what I am doing wrong.我无法弄清楚我做错了什么。 help!帮助!
string packageLocation = @"c:\packageLocationPath";
Package pkg;
Application app;
app = new Application();
pkg = app.LoadPackage(packageLocation, null);
var Resp = pkg.Execute();
First you have to read the errors raised by the package.首先,您必须阅读包引发的错误。 There are two options to detect these errors:有两个选项可以检测这些错误:
You can loop over the package errors by accessing Errors property.您可以通过访问 Errors 属性来遍历包错误。 As example:例如:
if(p.Errors.Count > 0){
foreach(DtsError err in p.Errors){
Messagebox.Show(err.Description);
}
}
More information at:更多信息请访问:
You can capture all errors, warning and information from a package by enabling logging option:您可以通过启用日志记录选项从包中捕获所有错误、警告和信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.