Variable cannot be found

Jul 20, 2009 at 2:59 PM
Edited Jul 20, 2009 at 3:52 PM

I am running through the getting started example, and have followed every step. However when I run the test's I get this error.

Exception occurred: Failed to lock variable "tableCount" for read access with error 0xC0010001 "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.".

Any ideas on what is causing this?

I found the offending line of code in the VariableCommand.cs that causes the error. However I'm not sure as to why.

   if (this.Operation== VariableOperation.Get)
  {
   
  dispenser.LockOneForRead(varName, ref vars);
  returnValue = vars[varName].Value;
  vars.Unlock();

 

 

Coordinator
Jul 20, 2009 at 9:02 PM

Not sure - have you made sure the unit test points to the appropriate location for your SSIS package? Are you using the Package file that was included in the zip, or one of your own? Have you verified that the package has a tableCount variable in it?

Jul 21, 2009 at 9:56 AM
Edited Jul 21, 2009 at 10:11 AM

Thank you for your response.

I managed to get some further information regarding the issue.

When setting up the package in VS, the instructions specify to  Mark the result set as a Single Row. However when executing the package in VS the package does not execute correctly. IF I change the ResultSet to none, the package executes but then the Unit Tests fails.

 

If I change the ResultSet to SingleRow I get the following error in my SSISunit

 

Assert 21/07/2009 10:59:26 Package Get Table Count Get Table Count Task Error: There is an invalid number of result bindings returned for the ResultSetType: "ResultSetType_SingleRow". False

 

Test 21/07/2009 10:59:26 Package Get Table Count Get Table Count Exception occurred: Failed to lock variable "tableCount" for read access with error 0xC0010001 "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.".
 False

 

Any Ideas?

 

Coordinator
Jul 21, 2009 at 1:28 PM

Yes, you need to create a variable named tableCount of type Int32 in the package. Then, set the Resultset to SingleRow in the Execute SQL Task, and go to the Result Set page (on the left side of the Execute SQL Task's editor window). Click Add, and set the result name to 0 (which indicates that you want the first column in the resultset) and the variable to the tableCount variable you just created.