本文介绍了如何传递变量的SSIS包从C#应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上我试图建立一个使用SSIS运行一系列的SQL的东西应用
Basically i am trying to build an application that uses SSIS to run a series of sql stuff.
下面是我的代码至今:
public JsonResult FireSSIS()
{
string x = string.Empty;
try
{
Application app = new Application();
Package package = null;
package = app.LoadPackage(@"C:\ft\Package.dtsx", null);
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();
if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
{
x += string.Concat("Package Execution results: {0}", local_DtsError.Description.ToString());
}
}
}
catch (DtsException ex)
{
// Exception = ex.Message;
}
return Json(x, JsonRequestBehavior.AllowGet);
}
是否有人知道如何传递给包本身的变量这种方式?
Does anybody know how to pass a variable to the package itself in this way?
推荐答案
试一下:
Microsoft.SqlServer.Dts.RunTime.Variables myVars = package.Variables;
myVars["MyVariable1"].Value = "value1";
myVars["MyVariable2"].Value = "value2";
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute(null, myVars, null, null, null);
这篇关于如何传递变量的SSIS包从C#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!