Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 error "variable can not be found..." while executi

Author  Topic 

Roswell123
Starting Member

1 Post

Posted - 2010-06-30 : 10:08:14
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!!!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-30 : 12:25:19
should be something like this?


Dim vars As Variables
ssisPackage.VariableDispenser.LockOneForWrite("FileName", vars)
vars("FileName").Value = "c:\filename.txt";
vars.Unlock()


SOURCE:
http://www.eggheadcafe.com/community/aspnet/17/10116415/launching-ssis-package-fr.aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -