June 30, 2010 at 7:56 am
Hi All,
I am trying to execute SSIS package from the .net Framework.
I have a User Variable available in my SSIS package to dynamically pass file name to the flat file source.
Package executes successfully If i ignore Variable passing part from my code. But If I set variable in my code and then execute the package, it gets failed.
I am getting the following error:
"The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created."
Below is my code:
Microsoft.SqlServer.Dts.Runtime.Application app=new Microsoft.SqlServer.Dts.Runtime.Application();
Package pkgIn = new Package();
string pkgLocation;
DTSExecResult pkgResults;
pkgLocation =@"c:\Package1.dtsx";
pkgIn.Variables["FileName"].Value = @"c:\filename.txt";
pkgIn = app.LoadPackage(pkgLocation, null);
pkgResults = pkgIn.Execute();
MessageBox.Show(pkgResults.ToString());
FYI : I have created User Variable in my package and it executes without any error if i run a package from the BIDS.
Thanks in advance!!!
July 6, 2010 at 2:04 pm
I assume that is the code that works, at first blush it would seem to.
I do have a question, you said "If i ignore Variable passing part from my code"
I'm asusming you are putting that code between the load and the exec?
What does that line look like?
CEWII
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply