Reputation:
I have similar code for vb and .net which runs my SSIS package just fine. The problem is the c# code and .net does not run my .dtsx package. I get all sorts of errors in cluding not being able to find the file on my desktop. I tried remotely running the package and locally. Is it my code. I am not sure what to do next. I do have all the correct references.
// public class clsSSIS1
// {
// public static void RunDTSX()
// {
// string pkgLocation;
// pkgLocation = "C:\\Documents and Settings\\otmxm1\\Desktop\\LoadBeaPayroll\\LoadBeaPayroll\\bin\\package.dtsx";
// Application app = new Application();
// Package package = null;
// Package pkg = app.LoadPackage(pkgLocation, null,true);
//Package pkg = app.LoadPackage(@"C:\Documents and Settings\otmxm1\Desktop\LoadBeaPayroll\LoadBeaPayroll\bin\package.dtsx", null);
// DTSExecResult result = package.Execute();
//Console.WriteLine (result.ToString);
// Console.ReadKey();
// }
// }
// }
Upvotes: 0
Views: 5195
Reputation: 627
Why not just execute the
dtexec.exe -f package.dtsx /conf ConfigurationIfYouGotOne
using System.Diagnostics.Process.Start(xxx)
?
Or if the the SSIS is deployed to a SQL Server, you can execute it with a stored procedure.
Upvotes: 1
Reputation: 349
Here is a good example I found:
Start the Visual Studio development environment, and create a new application in your preferred development language. This example uses a console application; however you can also run a package from a Windows Forms application, an ASP.NET Web form or Web service, or a Windows service.
On the Project menu, click Add Reference and add a reference to Microsoft.SqlServer.ManagedDTS.dll. Click OK.
Use the Visual Basic Imports statement or the C# using statement to import the Microsoft.SqlServer.Dts.Runtime namespace.
Add the following code in the main routine. The completed console application should look like the following example.
string pkgLocation;
Package pkg;
Application app;
DTSExecResult pkgResults;
pkgLocation =
@"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services" +
@"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
pkgResults = pkg.Execute();
Console.WriteLine(pkgResults.ToString());
Source: http://msdn.microsoft.com/en-us/library/ms136090.aspx
Upvotes: 1