Setting and the using a Variable in an ssis package for dynamic source file connection.

  • I apologize if I am in the wrong area but it has been difficult to find any thing close to what I am trying to accomplish.

    I am developing a ssis package that has a flat file source. the file name is 060315.txt , I have a script task that will build the 060315 portion of the connection string. I have created a Package level variable User::Filename set to type of string. When setting the value of the variable I get the following error ;

    Error: 0xC001F009 at Package: The type of the value (Empty) being assigned to variable "User::FileName" differs from the current variable type (String). Variables may not change type during execution. Variable types are strict, except for variables of type Object.

    Task failed: Script Task

    I can't use an datatype of object as it cannot be used in the following expression "\\\\fmhqnetapp2\\ERPShare\\" + @[User::FileName] +".txt" (used in the data source connection)

    script task code:

    Variable FileName has a scope of Package, Data type string, value is the original 060315.

    public void Main()

    {

    // TODO: Add your code here

    string filename = System.DateTime.Today.ToString("MMddyy");

    if (Dts.VariableDispenser.Contains("User::FileName"))

    {

    //Dts.Variables.Add("User::FileName", false, "ST_0c0c55960b724d26a9dd0f5a98340b5c", filename);

    //MessageBox.Show(Dts.Variables.Count.ToString());

    Dts.Variables["User::FileName"].Value = filename;

    Dts.TaskResult = (int)ScriptResults.Success;

    }

    else

    {

    Dts.TaskResult = (int)ScriptResults.Failure;

    }

    }

    Thanks in advance;

  • You should step thru the script and see what the value of filename when you try to assign it to the SSIS variable. Look like the error message it's Empty.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

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