none
Getting error "Failed to Lock variable [File Full path] for read access with error 0xC0010001. Vairable not found.. " when using Foreach container and file system task

    Question

  • I am trying to copy all CSV files from one folder to another. Below are the steps I took
    Foreach Container
    1.  Set the enumerator for foreach container to file Enumerator
    2. Set the source folder
    3. Set file to *.csv
    4. under the retrieve file name, I selected name and extension
    5. Under the Variable mappings I have User::filename as varaible and 0 as index

    File system task
    1.
    Set the IsDestinationPathVariable to True
    2. Set DestinationVariable to User::ArchiveFolder
    3. under operation, set to copy file
    4. IsSourcePathVariable to true

    Note: my file task is inside the foreach container

    When I run my package i get the error

    Error: Failed to lock variable "C:\Activity Account.csv" 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.".

    Does anyone know how to fix these problem?

    Thanks,

    • Edited by Jason.Smith Friday, June 26, 2009 6:06 PM fixing double encoded title
    Sunday, June 21, 2009 7:07 AM

Answers

  • It seems like you've set your IsSourcePathVariable to true - but then typed in the path name to the source file, not the variable itself.

    I say this because I would expect SSIS to complain that it "Failed to lock variable "User::filename" for read...".  Instead, it complained about not being able to find a variable called "C:\Activitiy Account.csv" - which does not appear to exist in your package.  Did you attempt to use Property Expressions on the file system task?
    Todd McDermid's Blog
    Sunday, June 21, 2009 6:28 PM
    Moderator

All replies

  • What is the scope of the filename variable. Make sure it is at the Foreach or higher. If you have Bidshelper installed you can change the scope if not you will have to remove the existing filename variable and add another one at the correct level

    The other option is the case of the variable differs i.e. Filename and filename.
    SQL Server MVP http://sqlblogcasts.com/blogs/simons SQL Know How - SQL Server Consultancy and Real world training - http://sqlknowhow.com/ SQLBits - Largest SQL Server Conference in Europe and its free - http://sqlbits.com
    Sunday, June 21, 2009 5:06 PM
  • It seems like you've set your IsSourcePathVariable to true - but then typed in the path name to the source file, not the variable itself.

    I say this because I would expect SSIS to complain that it "Failed to lock variable "User::filename" for read...".  Instead, it complained about not being able to find a variable called "C:\Activitiy Account.csv" - which does not appear to exist in your package.  Did you attempt to use Property Expressions on the file system task?
    Todd McDermid's Blog
    Sunday, June 21, 2009 6:28 PM
    Moderator