1
Answer

eRROR

Abhishek  Jaiswal

Abhishek Jaiswal

10y
709
1
hELLO FOLKS!
 
AM GETTING THIS ERROR IN MY CODE, PLS HELP
(am trying to create a package using SSIS and use it in my aspx.cs page in order to import data from Excel to SQL server)

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.

Line 48:  
Line 49: vars = pkg.Variables;
Line 50: vars["A_Variable"].Value = "SomeValue";
Line 51:
Line 52: pkgResults = pkg.Execute(null, vars, null, null, null);


here's my code

protected void Btntech_Click(object sender, EventArgs e)
{
string pkgLocation = @"C:\Users\abhishek\Documents\Visual Studio 2008\Projects\Camp\Camp\Package.dtsx";

Package pkg;
Application app;
DTSExecResult pkgResults;
Variables vars;

app = new Application();
pkg = app.LoadPackage(pkgLocation, null);

vars = pkg.Variables;

vars["A_Variable"].Value = "SomeValue";

pkgResults = pkg.Execute(null, vars, null, null, null);

if (pkgResults == DTSExecResult.Success)
Console.WriteLine("File Uploaded Successfully!");
else
Console.WriteLine("Failed, Try Again!");
}
 

Answers (1)