Executing FTP Task within For Each Container

  • I'm trying to run an FTP Task within a For Each container. I want all of the *.sbi files out of a C:\SCLFeed folder to be selected and sent via FTP to a remote server.

    I used the Foreach From Variable Enumerator and created a Variable Mapping to a blank variable User::FileWeJustFound. I tried to connect the For Each container to the FTP Task by having the IsLocalPathVariable property of the FTP Task set to True and the LocalVariable set to User::FileWeJustFound.

    When I run my SSIS package in BIDS (which creates proprietary flat files with an *.SBI extension and renames the files created with the current date and time appended to the filename) I get a red colour inside the FTP Task and the error message says that User::FileWeJustFound is empty. :unsure: What gives? I thought that the For Each container would provide each *.SBI file and feed it to the FTP Task through the User::FileWeJustFound variable. :ermm: What am I missing?????

  • I think it is better to use the For Each File container.

    Point this container to the right directory and set up which files he must loop (.xls or .csv or ...). Configure this either with hard-coded values or through expressions.

    Then, at the Variable Mappings pane, map your variable User::FileWeJustFound to index 0.

    Finally, use this variable to configure your FTP task.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I changed according to your suggestion, and when I ran it I got this as an error message - "Error: 0xC002917C at FTP Task, FTP Task: The variable "User::FileWeJustFound" doesn't contain file path(s).

    Task failed: FTP Task"

    Is there a way that I can see what the User::FileWeJustFound variable contains - like stepping through the event code or something?:discuss:

  • you can set up a watch window...or you could just add a script task with a message box.

  • Sorry, I forgot.

    In 2008, the For Each loop returns the directory + the filename, in 2005 only the filename is returned.

    So, you need to construct an expression that looks like:

    "\"" + @[User::Directory] + @[User::FileWeJustFound] + "\""

    I placed " around the expression so that it still works if the filename or directory has spaces in it.

    If necessary, you need to place a \ between the directory and the filename.

    To answer your debugging question:

    set up a breakpoint at the first task in the loop.

    Run your package and then wath the 'locals' window. You can find the variable value there.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Will give this a try and see how it works!:-D

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply