从c#调用SSIS包 [英] Calling SSIS package from c#

查看:276
本文介绍了从c#调用SSIS包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SSIS中使用脚本任务来使用具有自定义绑定的WCF服务,包括DtsDebugHost.exe.config下的配置信息,因为我没有其他选项,直到这里它很好,现在我需要调用SSIS包来自c#,我无法做到。

I am using Script Task in SSIS to consume WCF Service which has custom binding,included the config information under DtsDebugHost.exe.config as i have no other option,till here it is fine,now i need to call the SSIS package from c# which i am not able to do.

推荐答案

请参阅以下链接



http://stackoverflow.com/questions/273751/how-to-execute-an- ssis-package-from-net [ ^ ]



http://forums.asp.net/t/1831048.aspx/1 [ ^ ]
Refer below link

http://stackoverflow.com/questions/273751/how-to-execute-an-ssis-package-from-net[^]

http://forums.asp.net/t/1831048.aspx/1[^]


在项目中添加以下引用 - Microsoft.SqlServer.ManagedDTS

并在命名空间中使用Microsoft.SqlServer.Dts.Runtime添加;



protected void btn_get_Click(object sender,EventArgs e)

{

Microsoft.SqlServer.Dts.Runtime.Application MyApp = new Application();

MyApp.PackagePassword =abcd; //如果SSIS包是通过密码开发的。

包Mypac = MyApp.LoadPackage(@< ssis package =path =>,null);

DTSExecResult Myres = Mypac.Execute();

//这是为了在执行SSIS包时找到确切的错误。

if(Myres == Microsoft.SqlServer。 Dts.Runtime.DTSExecResult.Failure)

{

string err =;

foreach(Microsoft.SqlServer.Dts.Runtime.DtsError Mypac.Errors中的local_DtsError)

{

string error = local_DtsError.Description.ToString();

err = err + error;

}

txt_result.Text = err.ToString();

}

}



希望这可以帮到你。
Add following reference in your project - Microsoft.SqlServer.ManagedDTS
And in namespace add using Microsoft.SqlServer.Dts.Runtime;

protected void btn_get_Click(object sender, EventArgs e)
{
Microsoft.SqlServer.Dts.Runtime.Application MyApp = new Application();
MyApp.PackagePassword = "abcd"; //if SSIS package is procted by password.
Package Mypac = MyApp.LoadPackage(@"<ssis package="" path="">", null);
DTSExecResult Myres = Mypac.Execute();
//This is to find exact error while executing SSIS package.
if (Myres == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
string err = "";
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in Mypac.Errors)
{
string error = local_DtsError.Description.ToString();
err = err + error;
}
txt_result.Text = err.ToString();
}
}

Hope this may help you.


这篇关于从c#调用SSIS包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆