Fowlloing code is used to excute SSIS package from web or windows applications.
First we need to add reference Microsoft.SqlServer.ManagedDTS to the project ( Right click on References. Click on 'Add Reference'. It will pop up Add reference window. select Microsoft.SqlServer.ManagedDTS under .NET components and click on OK).
HTML Source:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Excute SSIS package from .NET application</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnExcute" runat="server" OnClick="btnPackage_Click" Text="Excute Package" />
</div>
</form>
</body>
</html>
C# Code:
protected void btnPackage_Click(object sender, EventArgs e)
{
string filename = "C:/Documents/Projects/TestPackage/bin/Deployment/test.dtsx";
Application app = new Application();
Package pckg = null;
try
{
pckg = app.LoadPackage(filename, null);
DTSExecResult result = pckg.Execute();
}
catch (Exception ex)
{
throw ex;
}
finally
{
pckg.Dispose();
}
}
No comments:
Post a Comment