Issue with code in script task

  • I have this piece of code in script task when the package is running It will check for SDB database name if it is adventure then it will go into if condition and start getting data from emp table.
    The variable Vartab is created at package level there i set as string as datatype. When I run the package its giving me error I tried to convert Dts.Variables["User::VarTab"].Value = strTable.tostring(); still facing error - Exception has been thrown by target of invocation

     string strTable = "select top 10 * from EMP";
                if (Dts.Variables["User::SDB"].Value.ToString() == "ADVENTURE")
                {
                    Dts.Variables["User::VarTab"].Value = strTable;
                }

  • mcfarlandparkway - Tuesday, February 7, 2017 9:23 AM

    I have this piece of code in script task when the package is running It will check for SDB database name if it is adventure then it will go into if condition and start getting data from emp table.
    The variable Vartab is created at package level there i set as string as datatype. When I run the package its giving me error I tried to convert Dts.Variables["User::VarTab"].Value = strTable.tostring(); still facing error - Exception has been thrown by target of invocation

     string strTable = "select top 10 * from EMP";
                if (Dts.Variables["User::SDB"].Value.ToString() == "ADVENTURE")
                {
                    Dts.Variables["User::VarTab"].Value = strTable;
                }

    Is Dts.Variables["User::VarTab"] in your list of read/write variables for the script task?

    And remember, using select * in production code is usually a bad idea.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • TY So much,Resolved.

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

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