Script to Get File path from a connection manager

  • Hi all -

    I'm very green in SSIS but I've been thrown into a major project and tasked with putting in some error handling. Specifally, I need to check for existance of a file in a folder prior to trying to operate on it. The package uses about 15 flat file connection managers. In each of the main steps of the package I need to get the file path from the connection manager for that process, then check for existance at that path. I am totally stuck on getting the file path from the connection manager.

  • Uripedes Pants (4/19/2012)


    Hi all -

    I'm very green in SSIS but I've been thrown into a major project and tasked with putting in some error handling. Specifally, I need to check for existance of a file in a folder prior to trying to operate on it. The package uses about 15 flat file connection managers. In each of the main steps of the package I need to get the file path from the connection manager for that process, then check for existance at that path. I am totally stuck on getting the file path from the connection manager.

    This should get you going in the right direction. I just tested it and it provides the proper answer even when the ConnectionString property is setup to come from a Variable setup to derive it's value from an Expression.

    In a Script Task:

    foreach (var conn in this.Dts.Connections)

    {

    if (conn.Name == "newFile")

    {

    Console.WriteLine(conn.ConnectionString);

    }

    }

    * SSIS 2008 C#

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • thanks, opc.three

    that should give me a good push. I'm way over my head in this, but I think I can muddle through... with proper nudging along the way.

  • Happy to assist, you're in the right place to pickup a few good nudges here and there 😉

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 4 posts - 1 through 3 (of 3 total)

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