Pass variables to child via C# script task ?

I don't want to use package configurations to pass variables from Parent to child package. I'd prefer to pass the variables to child, from a  C# script task in the parent package. Can this be done ? Here is the pseudocode for what I hope to do - 
//code in script task of parent package
Main(){
Object parentObj = SSIS.ParentPackage.myObject;
String parentStr =  SSIS.ParentPackage.myString;
callChildPackage(parentObj, parentStr);

You have four choices for this:
Use Parent-Child variable configurations
Place the value in a variable in the parent package, which can be referenced from the child package, when run with an Execute Package Task. (http://agilebi.com/jwelch/2009/10/03/passing-an-object-from-a-parent-package-to-a-child)
Take over the execution of the child package entirely executing the package from inside your C# script task.
Use something like the Task Factory Advanced Execute Package task. (Full Disclosure: I work for Pragmatic Works)
Item 3 is probably closest to what you want. You'd need to use the Package.Execute method to run the child package yourself. The advantage of doing that is you can set child package variables explicitly before executing the package.
John Welch | www.pragmaticworks.com | www.agilebi.com | ssisUnit.codeplex.com

Similar Messages

  • Passing binds to Child reports / detail script reports

    Hi,
    I've been trying to figure out (assuming it's possible) how to pass bind variables to child / detail PL sql script reports.
    I've made sure to declare the binds tab, and made sure it saved. However, if I try something like:
    exec dbms_output.put_line(:VAR);
    I get bind variable not declared. Any ideas what I'm doing wrong?
    Thanks.

    Make sure that the value you are trying to pass to the child/detail report exists as a column in the parent/master report. Second make sure that the bind name in the child/detail report is in ALLCAPS.
    I don't know of any other way to pass bind values to child reports than via the parent query, and the all caps requirement catches me often enough.

  • Get an Alter XMLA string via C# script task

    Hi,
    I have an alter Database XMLA file that needs to be deployed to an Analysis Server only if there was a change with the existing database.
    I have a C# script task that checks if the DB exists before deploying.
    What I need to add, is code that compares the alter Database XMLA file with the existing DB metadata.
    It would be good enough to get code example of how to extract the XMLA using AMO.

    Hi ,
      Please refer the below link for sample code 
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5b17c421-699d-4dbf-849c-0531f4e0411e/extract-the-xml-form-dsv-and-cube-through-net
    Best Regards Sorna

  • Passing variables from DM to logic script problem (REPLACEPARAM)

    Dear All,
    I would like to send variables from data manager to a logic script. The script copies values from an account to an other. If I hardcode two accounts in the script, it works fine, but I want to pass these two accounts dynamically from data manager to the script.
    My advanced script in DM looks as follows:
    PROMPT(SELECTINPUT,%ENTITY_M%,,"Select entity:","ENTITY_DIM")
    PROMPT(SELECTINPUT,%SOURCE%,,"Select source account:","ACCOUNT_DIM")
    PROMPT(SELECTINPUT,%TARGET%,,"Select target account:","ACCOUNT_DIM")
    INFO(%EQU%,=)
    INFO(%TAB%,;)
    TASK(PROCESS_CHAIN_RUNL,TAB,%TAB%)
    TASK(PROCESS_CHAIN_RUNL,EQU,%EQU%)
    TASK(PROCESS_CHAIN_RUNL,SUSER,%USER%)
    TASK(PROCESS_CHAIN_RUNL,SAPPSET,%APPSET%)
    TASK(PROCESS_CHAIN_RUNL,SAPP,%APP%)
    TASK(PROCESS_CHAIN_RUNL,SELECTION,%ENTITY_M%)
    TASK(PROCESS_CHAIN_RUNL,LOGICFILENAME,ACCOUNT_COPY_LOGIC.LGF)
    TASK(PROCESS_CHAIN_RUNL,MEMBERSELECTION,SOURCE%EQU%%SOURCE%%TAB% TARGET%EQU%%TARGET%)
    In the logic script, I'm using $SOURCE$ and $TARGET$ as variables, but it seems that only the first of them gets the value from DM, the other one not, and I always get an error message:
        Member "$TARGET$" not exist
    The second variable doesn't seem to get the value. If I use only one variable, either SOURCE or TARGET, it works fine...
    ...and I also tried to replace the MEMBERSELECTION statement with a REPLACEPARAM statement:
    TASK(PROCESS_CHAIN_RUNL,REPLACEPARAM,SOURCE%EQU%%SOURCE%%TAB% TARGET%EQU%%TARGET%)
    This way I got an other error message, saying: "Member .../PrivatePublications/user not exist"
    Do you have any idea? How to pass two user selected parameters to a logic script?
    Thanks for your help,
    A.

    Hi CsernusAttila
    You cannot use ACCOUNT_DIM with promp SELECT  and variable $SOURCE$ because it only works with variable ACCOUNT_SET in your script logic.
    instead of you can use TEXT
    PROMPT(TEXT,%,ENTITY_M%%,"Select Entity",)
    PROMPT(TEXT,%,SOURCE%%,"Select Source",)
    PROMPT(TEXT,%,TARGET%%,"Select Target",)
    INFO(%EQU%,=)
    INFO(%TAB%,;)
    TASK(PROCESS_CHAIN_RUNL,TAB,%TAB%)
    TASK(PROCESS_CHAIN_RUNL,EQU,%EQU%)
    TASK(PROCESS_CHAIN_RUNL,SUSER,%USER%)
    TASK(PROCESS_CHAIN_RUNL,SAPPSET,%APPSET%)
    TASK(PROCESS_CHAIN_RUNL,SAPP,%APP%)
    TASK(PROCESS_CHAIN_RUNL,SELECTION,%SELECTION%)
    TASK(PROCESS_CHAIN_RUNL,LOGICFILENAME,ACCOUNT_COPY_LOGIC.LGF)
    TASK(PROCESS_CHAIN_RUNL,REPLACEPARAM,SOURCE%EQU%%SOURCE%%TAB% TARGET%EQU%%TARGET%)
    or you can modify your script like this
    *XDIM_MEMBERSET ACCOUNT=%ACCOUNT_SET%
    *XDIM_MEMBERSET ENTITY=%ENTITY_SET%
    And your Prompt like this
    PROMPT(SELECTINPUT,,,,"%ACCOUNT_DIM%,%ENTITY_DIM%,")
    TASK(PROCESS_CHAIN_RUNL,TAB,%TAB%)
    TASK(PROCESS_CHAIN_RUNL,EQU,%EQU%)
    TASK(PROCESS_CHAIN_RUNL,SUSER,%USER%)
    TASK(PROCESS_CHAIN_RUNL,SAPPSET,%APPSET%)
    TASK(PROCESS_CHAIN_RUNL,SAPP,%APP%)
    TASK(PROCESS_CHAIN_RUNL,SELECTION,%SELECTION%)
    TASK(PROCESS_CHAIN_RUNL,LOGICFILENAME,ACCOUNT_COPY_LOGIC.LGF
    I hope it helps
    Regards!!

  • Pass variable from apex to shell script

    Hi,
    i am able to use apex button to run a db scheduler job and use the the job to run an OS bash script, but don't know how to pass an variable to the script from apex.

    Hi,
    Thansk for the reply.
    My scenario is
    1. Apex page 1: Store List Report, click the store you want to process, the selected store id and store name will be passed to apex page 2 automatically.
    2. Apex page 2: Show the store ID and Store Name, once confirm click a button on the screen. I already created dynamic action of the button to run a bash script in OS via dbms_scheduler.
    My issue is i don't know how to get the store id and pass it to the bash script through dbms_scheduler.
    Regards
    Lion

  • C# SSIS Script component - Save List String to Object package-scope variable and read it in Script Task

    before posting this i was searching this on internet but was not able to find info regarding my specific case:
    i have a DataFlow Task with "Error output" pointing from FlatFile to
    Script Component that does below (variable "ErrorMessageList" is listed under ReadWriteVariables property):
    List<string> lsErrors = new List<string>();
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    lsErrors.Add("test1");
    lsErrors.Add("test2");
        void PostExecute()
            base.PostExecute();
            Variables.ErrorMessageList = lsErrors;
    Then the DataFlow points to a ScriptComponent where this object variable is listed under ReadOnlyVariables property and does the below:
    public void Main()
    List<string> lsErrors = (List<string>)Dts.Variables["ErrorMessageList"].Value;
    and that is where i get exception-has-been-thrown-by-the-target-of-an-invocation
    What is wrong here?
    (i have mistakenly edited this first post before, so i tried to manually put it back to original version)

    i have missed the "override" keyword...
    public class ScriptMain : UserComponent
    public class UserComponent: ScriptComponent
    namespace Microsoft.SqlServer.Dts.Pipeline
    public class ScriptComponent
    // i should have seen this before
    public virtual void PostExecute();
    i believe i must have deleted the PostExecute method definition right after the ScriptComponent generated the script for me... and then when i've realized that i can't change ReadWriteVariables as a part of:
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    // --- can't change ReadWriteVariables here
    then i had to add the method back but forgot that the base method is virtual
    thanks for this hint, Russ!

  • Passing variable from sql to shell script

    Usually we can pass arguments from shell script to the sql that us called inside the shell script. But I also want to do the reverse. I have the location of my backup path in a table. I want to run the rman script (shell), read this parameter from the table and use this to construct the "format" path in rman. Anyone has any ideas about this. Thanks.

    To achieve getting the modified value from the table everytime the job runs, I encapsulated this in another job.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
    JOB_NAME           => 'TEST_LOGS_MAIN',
    JOB_TYPE             => 'PLSQL_BLOCK',
    JOB_ACTION          => 'declare
    v_aname varchar2(32);
    begin
    select aname into v_aname from attr where attrid = 3;
    DBMS_SCHEDULER.CREATE_JOB(
    JOB_NAME        => ''TEST_LOGS'',
    JOB_TYPE        => ''EXECUTABLE'',
    JOB_ACTION      => ''/opt/sql/testy.sh'',
    number_of_arguments => 1,
    COMMENTS        => ''TEST'');
    dbms_scheduler.set_job_argument_value(''TEST_LOGS'',1,v_aname);
    dbms_scheduler.enable(''TEST_LOGS'');
    end;',
    REPEAT_INTERVAL => 'FREQ=MINUTELY',
    ENABLED           => TRUE);
    END;
    /

  • SQL 2008 R2 - SSIS C# Script Task - Not Setting Variable

    OK... I am stumped.  I am trying to set the variable "User::TicketDB_Get_SQL" from a Script Task since it is dynamic... and well it isn't working :(
    I can see I am supposed to be setting the value, but when I do breaks and watch that variable the new value is not being set.  Here is my C# code... Can someone look and see what the heck I might be doing wrong:
    Microsoft SQL Server Integration Services Script Task
    Write scripts using Microsoft Visual C# 2008.
    The ScriptMain is the entry point class of the script.
    using System;
    using System.IO;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using System.Text.RegularExpressions;
    namespace ST_3542610d50a64788be84926d15e07f7b.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    public void Main()
    //MessageBox.Show("Start VB");
    //MessageBox.Show("Make ADO Connection");
    SqlConnection sqlConn = new SqlConnection();
    sqlConn = (SqlConnection)(Dts.Connections["ADO-DW-SSIS_Processing"].AcquireConnection(Dts.Transaction) as SqlConnection);
    SqlConnection sqlTicketDBRowsConn = new SqlConnection();
    sqlTicketDBRowsConn = (SqlConnection)(Dts.Connections["ADO-DW-SSIS_Processing"].AcquireConnection(Dts.Transaction) as SqlConnection);
    //MessageBox.Show("Connected to ADO");
    String newSelectSQL = null;
    //bool fireAgain = false;
    Variables vars = null;
    try
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_Max_Modified_Date");
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_Prod_Table");
    Dts.VariableDispenser.LockForRead("User::Modified_Date_Field");
    Dts.VariableDispenser.LockForRead("User::TicketDB_Schema");
    Dts.VariableDispenser.LockForRead("User::Table_Name");
    Dts.VariableDispenser.LockForRead("User::Unique_ID_Field");
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_Process_Table_Name");
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_DB_Name");
    Dts.VariableDispenser.LockForWrite("User::TicketDB_Get_SQL");
    Dts.VariableDispenser.LockForWrite("User::Reprocess_Records");
    Dts.VariableDispenser.GetVariables(ref vars);
    //Dts.VariableDispenser.GetVariables(ref glvars);
    String maxModDate = vars["User::Data_Warehouse_Max_Modified_Date"].Value.ToString();
    String prodtable = vars["User::Data_Warehouse_Prod_Table"].Value.ToString();
    String modField = vars["User::Modified_Date_Field"].Value.ToString();
    String TicketDBSchema = vars["User::TicketDB_Schema"].Value.ToString();
    String tablename = vars["User::Table_Name"].Value.ToString();
    String uniqIDField = vars["User::Unique_ID_Field"].Value.ToString();
    String procTable = vars["User::Data_Warehouse_Process_Table_Name"].Value.ToString();
    String custName = vars["User::Data_Warehouse_DB_Name"].Value.ToString();
    String Reprocess = "F";
    String ReprocessDate = "0";
    String ReprocessPrime = null;
    String ReprocessVal = null;
    Int16 count = 0;
    #region Get List of Rows for TicketDB Query
    String TicketDBRows = null;
    String sqlTicketDBRowsQuery = "SELECT [TicketDB_Column_Name] " +
    "FROM " + procTable + " " +
    "WHERE " +
    "[Import_Data_Warehouse] = 1 " +
    "AND " +
    "[TicketDB_Table_Name] = '" + tablename + "' " +
    "ORDER BY [TicketDB_Column_Name]";
    SqlCommand sqlTicketDBRowsCmd = new SqlCommand(sqlTicketDBRowsQuery, sqlTicketDBRowsConn);
    SqlDataReader sqlTicketDBRowsReader = sqlTicketDBRowsCmd.ExecuteReader();
    Int16 TicketDBrowcount = 0;
    while (sqlTicketDBRowsReader.Read())
    if (TicketDBrowcount > 0)
    TicketDBRows += ", ";
    TicketDBRows += " " + sqlTicketDBRowsReader.GetString(0) + " ";
    TicketDBrowcount++;
    #endregion
    String Pattern = @"(\D)\s-\s(\d+)(\s-\s(.*)\s-\s(.*))?";
    String ReProcessFile = null;
    if (prodtable.Equals("Template")) {
    ReProcessFile = "E:\\Templates\\Configs\\" + prodtable + "-Reprocess.txt";
    else
    ReProcessFile = "E:\\SSIS_Configs\\" + custName + "\\" + prodtable + "-Reprocess.txt";
    #region Process Re-Process File
    if (File.Exists(ReProcessFile))
    //MessageBox.Show("File is found");
    using (StreamReader sr = new StreamReader(ReProcessFile))
    //MessageBox.Show("File has been opened");
    string line;
    while ((line = sr.ReadLine()) != null)
    //MessageBox.Show("Found a Line: " + line);
    Regex rgx = new Regex(Pattern, RegexOptions.IgnoreCase);
    MatchCollection matches = rgx.Matches(line);
    foreach (Match match in matches)
    GroupCollection groups = match.Groups;
    Reprocess = groups[1].Value;
    ReprocessDate = groups[2].Value;
    ReprocessPrime = groups[4].Value;
    ReprocessVal = groups[5].Value;
    //MessageBox.Show("Variables Set." + Environment.NewLine +
    // "Reprocess: " + Reprocess + Environment.NewLine +
    // "Reprocess Date: " + ReprocessDate + Environment.NewLine +
    // "Reprocess Primary Field: " + ReprocessPrime + Environment.NewLine +
    // "Reprocess Value Field: " + ReprocessVal);
    //MessageBox.Show("End Processing File");
    #endregion
    #region Re-Proccess Rows
    if (Reprocess.Equals("T"))
    if (String.IsNullOrEmpty(ReprocessPrime) && String.IsNullOrEmpty(ReprocessVal))
    else
    //MessageBox.Show("Finished Getting Read Only Variables");
    string sqlQuery = "SELECT TOP (1000) " + uniqIDField + " " +
    "FROM " + prodtable + " " +
    "WHERE " +
    "[" + ReprocessVal + "] IS NULL " +
    "AND " +
    "[" + ReprocessPrime + "] IS NOT NULL " +
    "ORDER BY [" + modField + "]";
    //MessageBox.Show("sqlQuery: " + sqlQuery);
    SqlCommand sqlCmd = new SqlCommand(sqlQuery, sqlConn);
    SqlDataReader sqlReader = sqlCmd.ExecuteReader();
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " WHERE "; // + modField + " > '" + maxModDate + "' ";
    while (sqlReader.Read())
    if (count == 0)
    newSelectSQL += " CASE_ID IN (";
    if (count > 0)
    newSelectSQL += ", ";
    newSelectSQL += "'" + sqlReader.GetString(0) + "'";
    count++;
    newSelectSQL += ") OR " + modField + " > '" + maxModDate + "' ORDER BY " + modField + " ASC";
    //sqlConn.Close();
    if (count == 0)
    //MessageBox.Show("Reprocess: " + Reprocess + Environment.NewLine + "Start Date: " + ReprocessDate);
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " " + "WHERE " + modField + " >= '" + ReprocessDate + "' ";
    newSelectSQL += "ORDER BY " + modField + " ASC";
    vars["User::Reprocess_Records"].Value = newSelectSQL.ToString();
    //Dts.Variables["User::Reprocess_Records"].Value = "T";
    else
    //MessageBox.Show("NO Reprocess: " + Reprocess + Environment.NewLine + "Max Date: " + maxModDate);
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " " + "WHERE " + modField + " > '" + maxModDate + "' ";
    newSelectSQL += "ORDER BY " + modField + " ASC";
    #endregion
    else
    //MessageBox.Show("NO Reprocess: " + Reprocess + Environment.NewLine + "Max Date: " + maxModDate);
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " " + "WHERE " + modField + " > '" + maxModDate + "' ";
    newSelectSQL += "ORDER BY " + modField + " ASC";
    //MessageBox.Show("Maybe New SQL: " + newSelectSQL.ToString());
    //Variables vars = null;
    MessageBox.Show("Got Variable now lets set it to: " + newSelectSQL.ToString());
    // Now you can use the variables
    vars["User::TicketDB_Get_SQL"].Value = newSelectSQL.ToString();
    MessageBox.Show("New SQL: " + vars["User::TicketDB_Get_SQL"].Value.ToString());
    //vars.Unlock();
    catch (Exception ex)
    //MessageBox.Show("Error :(");
    // Throw an exception or add some logging
    //this.Dts.Events.FireInformation(1, "Something Went Wrong", newSelectSQL.ToString(), "", 0, ref fireAgain);
    throw ex;
    //Dts.TaskResult = (int)ScriptResults.Failure;
    finally
    //MessageBox.Show("Trying to UNLock Variable");
    // Release the locks (even if your script task fails)
    vars.Unlock();
    //Dts.Variables["User::TicketDB_Get_SQL"].Value = newSelectSQL;
    //MessageBox.Show("New SQL: " + Dts.Variables["User::TicketDB_Get_SQL"].Value);
    Dts.TaskResult = (int)ScriptResults.Success;
    So that is my code... when I run it, line # 217 shows what the new Variable should be... However when I hit line # 220 it isn't set and if I let it continue I am watching the variables and it isn't getting set.  I am confused... anyone??
    Billy S.

    Hi Billy S,
    Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions.
    Thanks,
    Eileen
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here

  • Passing variables from shell script to separate sqlplus script

    Hi, I am having issues passing variables to a separate sqlplus script invoked by the shell script, e.g.
    #!/bin/sh
    DB_NAME=TEST
    PWD1=PA55W0rd
    echo exit | sqlplus / as sysdba @${DB_NAME}.sql ${DB_NAME} $PWD1 >> ${DB_NAME}.sql
    exit 0
    The script picks up the $DB_NAME variable fine, and therefore invokes the required sql script.
    However, when I pass the variable $PWD1 to the sql script I get an error.
    The script creates a database link:
    create or replace procedure new.link
    is
    begin
    execute immediate 'create database link TEST
    connect to TESTSCH identified by '$PWD1'
    using ''TEST''';
    end;
    exec new.link;
    output is:
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "NEW.LINK", line 4
    ORA-06512: at line 1
    any help appreciated!
    Edited by: 969765 on Apr 5, 2013 4:24 AM

    969765 wrote:
    that is a pretty unhelpful comment, this is actually my LAST resort I have looked up all the documentation etc.This is what I did...
    I went to the documentation:
    http://www.oracle.com/pls/db112/homepage
    I searched for "sqlplus" which gave me this documentation (under "SQL*plus program syntax")...
    http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_three.htm#i1169374
    I read the syntax:
    SQLPLUS [ [Options] [Logon|/NOLOG] [Start] ]and the subsequent information:
    >
    where Start has the following syntax:
      @{url|file_name[.ext]} [arg ...]and "Start" was hyperlinked, so I clicked on it, which took me to the section...
    >
    Start
    @} [arg ...]
    Specifies the name of a script and arguments to run. The script can be called from the local file system or from a web server.
    SQL*Plus passes the arguments to the script as if executing the file using the SQL*Plus START command. If no file suffix (file extension) is specified, the suffix defined by the SET SUFFIX command is used. The default suffix is .sql.
    See the START command for more information.
    >
    and here the "START" was hyperlinked, so I clicked on that...
    and hey presto, I ended up here:
    http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve044.htm#BACJJHDA
    ... where the arguments are described...
    >
    arg ...
    Data items you wish to pass to parameters in the script. If you enter one or more arguments, SQL*Plus substitutes the values into the parameters (&1, &2, and so forth) in the script. The first argument replaces each occurrence of &1, the second replaces each occurrence of &2, and so on.
    >
    ... clearly explaining that SQL*Plus substitutes the substitution variables &1, &2 etc. in the script with the passed in arguments.
    Your script was including a Unix style substitution, not an SQL*Plus script substitution, so that's seems to be the most likely cause of your problem.
    And still you haven't come back to say whether it's worked for you or not... leaving others guessing as to whether you still need help.

  • Problem with Script Task formatting excel

    Hi Experts,
    I am creating a package and using Script task to format one excel dimension file, now the problem is if I execute the package from BIDS designer with static values then the package executes fine with excel file formatted perfectly fine but if I execute same package in BPC via Data manager with values used from variables it gives error on script task message:
    "Description = System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'E:\PC_MS\Data\Webfolders\CDNPLAN\AdminApp\Stage\Employee.xls'. There are several possible reasons:
    u2022 The file name or path does not exist.
    u2022 The file is being used by another program.
    u2022 The workbook you are trying to save has the same name as a currently open workbook.
    at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
    at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
    at ScriptTask_2921447fa19c44dfae73d5370828ba94.vbproj.ScriptMain.Main()
    Now to crosscheck I commented the dynamic variables from the code and used same static values with Data manager as they are in BIDS but it didn't help, please find the code below and help me in solving this problem or just give me some clue to come out if this:
    Thanks & Regards,
    Rohit
    Code
    Public Sub Main()
              ' Add your code here
            'Dim FileName As String = Dts.Variables("MYWEBFOLDERS").Value & Dts.Variables("MYAPPSET").Value & "\AdminApp\Stage\" & Dts.Variables("MYDIMNAME").Value & ".xls" This I commented as it was using dynamic variables
            Dim FileName As String = "E:\PC_MS\Data\Webfolders\CDNPLAN\AdminApp\Stage\Employee.xls"
        Dim WB As Object ' Workbook
        Dim WS As Object 'Worksheet
        Dim W As Object 'Window
        Dim XL As Object 'Application
        XL = CreateObject("Excel.Application")
        XL.DisplayAlerts = False
        ' Open the workbook
        WB = XL.Workbooks.Open(FileName)
        ' WB = GetObject(FileName)
        '    XL = WB.Parent
        '    XL.DisplayAlerts = False
        WS = WB.Worksheets(1)
        W = WB.Windows(WB.Name)
        ' Change the name of the worksheet to MEMBERS
        WS.Name = "MEMBERS"
        ' Set up the split and freeze the panes
        W.SplitRow = 1
        W.SplitColumn = 1
        W.Split = True
        W.FreezePanes = True
        ' Make it visible
        W.Visible = True
        ' Replace *ID column header with ID
        Dim Row1 As Object
        Row1 = WS.UsedRange.Rows("1:1")
        Dim I As Integer
        For I = 1 To Row1.Columns.Count
          If Row1.Cells(I, 1).Value = "*ID" Then
            Row1.Cells(I, 1).value = "ID"
            Exit For
          End If
        Next
        ' Paste Values
        WS.UsedRange.NumberFormat = "@"
        WS.UsedRange.Value = WS.UsedRange.Value
        ' Change the font of everything to Arial,9
        With WS.Cells.Font
          .Name = "Arial"
          .Size = 9
        End With
        ' Format the top row to be bold and orange
        With WS.Rows("1:1")
          .Font.Bold = True
          .Interior.ColorIndex = 44 'orange
        End With
        ' Auto-fit all the columns
        WS.Cells.EntireColumn.AutoFit()
        ' Convert to Excel format
        Const xlNormal = -4143
        WB.Parent.DisplayAlerts = False
        WB.SaveAs(FileName:=FileName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False)
            ' Close and save changes
            WS = Nothing
            WB.Close()
            W = Nothing
        ' Quit Excel
            XL.Quit()
            XL = Nothing
        Dts.TaskResult = ScriptResults.Success
         End Sub

    Hi,
    If you do not define GLOBAL VARIABLE in your BPC package and BIDS, why don't you try to have it? you should specify the webfolder and file name in advanced script, then you also need to create global variable as text type in BIDS.
    I saw many cases BPC does not pass the dynamic variable to BIDS, therefore I changed the type of variable as the Global variable and it works for me.
    Regards,
    YH Seo

  • Script task destination

    hi
    i have 1 ssis variable which i am trying to use in my script task,but when i run its throwing an error.
    how to use curentdate here.i am passing as a read only in script task
        fileContents.AppendLine(String.Format("ABC" & Dts.Variables("CurentDate").Value.ToString()))
            fileContents.Append(File.ReadAllText(Dts.Connections("Destination").ConnectionString))
            File.WriteAllText(finalFile, fileContents.ToString())

    I would use something like this to
    add a footer to an existing file:
    string filePath = Dts.Connections["myFlatFile"].AcquireConnection(Dts.Transaction).ToString();
    using (StreamWriter sw = File.AppendText(filePath))
    sw.WriteLine(Dts.Variables["User::yourVariable"].Value.ToString());
    You could add some more formating to the string... but you could also add an expression to a variable to create the right string/footer.
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Script task within child package - breakpoint wont hit, trying to find missing variable

    Im calling a child package and its failing on a script task with a message which indicates one of the variables cant be found
    The script threw an exception: The element cannot be found in a collection.
    So I remove the readonly/readwrite section, and place a breakpoint on the very first line of the script task. When I run the main package, by breakpoint on the child package script task isnt hit but I still get the error about the missing variable.
    How can I find out which variable its complaining about?

    You can raise an event in the script using FireInformation and pass into it the variable content as string
    examples:
    http://technet.microsoft.com/en-us/library/ms136054.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
    The variable content will put into the Output window (go to View menu to enable it).
    Arthur My Blog

  • How do I Pass a parameter to a SQL Component Task where the source SQL statement is also a variable

    Hi,
    I have been tasked with making a complex package more generic.
    To achieve this I need to pass a parameter to a SQL Component Task where the source SQL statement is also a variable.
    So to help articulate my question further I have create a package and database as follows; -
    USE [KWPlay]
    GO
    /****** Object: Table [dbo].[tblTest] Script Date: 05/14/2014 17:08:02 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[tblTest](
    [ID] [bigint] IDENTITY(1,1) NOT NULL,
    [Description] [nvarchar](50) NULL,
    CONSTRAINT [PK_tblTest] PRIMARY KEY CLUSTERED
    [ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    I populated this table with a single record.
    I unit tested the SQL within SSMS as follows;
    SELECT * FROM dbo.tblTest
    Result; -
    ID           
    Description
    1             
    Happy
    DECLARE @myParam NVARCHAR(100)
    SET @myParam = 'Sad'
    UPDATE dbo.tblTest SET [Description] = @myParam FROM dbo.tblTest WHERE ID = 1
    SELECT * FROM dbo.tblTest
    Result; -
    ID   
    Description
    1    
    Sad
    Within the package I created two variables as follows; -
    Name: strSQL
    Scope: Package
    Data Type: String
    Value: UPDATE dbo.tblTest SET [Description] = @myParam FROM dbo.tblTest WHERE ID = 1
    Name: strStatus
    Scope: Package
    Data Type: String
    Value: Happy
    I then created a single ‘Execute SQL Task’ component within the control flow as follows; -
    However when I run the above package I get the following error; -
    SSIS package "Package.dtsx" starting.
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "UPDATE dbo.tblTest SET [Description] = @myParam FR..." failed with the following error:
    "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task
    Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. 
    The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the
    errors.
    SSIS package "Package.dtsx" finished: Failure.
    I also tried; - 
    Name: strSQL
    Scope: Package
    Data Type: String
    Value: UPDATE dbo.tblTest SET [Description] = ? FROM dbo.tblTest WHERE ID = 1
    However I received the error; - 
    SSIS package "Package.dtsx" starting.
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "UPDATE dbo.tblTest SET [Description] = ? FROM dbo...." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with
    the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task
    Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches
    the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
    SSIS package "Package.dtsx" finished: Failure.
    Kind Regards,
    Kieran.
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Tried; - 
    Name: strSQL
    Scope: Package
    Data Type: String
    Value: UPDATE dbo.tblTest SET [Description] = ? FROM dbo.tblTest WHERE ID = 1
    and; - 
    Result; - 
    SSIS package "Package.dtsx" starting.
    SSIS package "Package.dtsx" finished: Success.
    Therefore the answer was to put the parameter number rather than the parameter name under the parameter mapping tab-> parameter name column. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

  • Variable of Type "Object" is getting Null in script task

    I have 3 components as below
    1.   Execute Sql Task ---> It will fetch The data from Database using ConnectionType "OLEDB" ("Full Result Set" its returning) and Store it in the Variable as below,
          "ConfigDetails"   "Scope --> Package"    "Type -  Object".
    2.  Script Task  (First) ---->   Here "ConfigDetails" Variable is part of "ReadOnlyVariables", So i am accessing this varaible and populating data from it in the Data Table object as below,
    OleDbDataAdapter configAdapter = new OleDbDataAdapter();
    DataTable dtConfigurationList = new DataTable();
    object config = Dts.Variables["ConfigDetails"].Value;
    configAdapter.Fill(dtConfigurationList, config);
      So here i am successfull in populating data in the data table .
    3. Script Task (Second)--> Same thig i am doing in second script task also as "First"
    Here "ConfigDetails" Variable is part of "ReadOnlyVariables", So i am accessing this varaible and populating data from it in the Data Table object as below,
    OleDbDataAdapter configAdapter = new OleDbDataAdapter();
    DataTable dtConfigurationList = new DataTable();
    object config = Dts.Variables["ConfigDetails"].Value;
    configAdapter.Fill(dtConfigurationList, config);
     So here it will execute successfully without any error. But no data is there in the data table .
    If i skip first script task, second script task is able to populate the data. But i am not righting any code to nullify the object and its part of "Read Only Varaibles."
      So please help me what i am doing wrong.
                configAdapter.Fill(dtConfigurationList, config);

    What do you pass to the config variable?
    Arthur My Blog

  • Passing parameters with spaces to SCCM Run PowerShell Script task

    I am working on an OS deployment task sequence in SCCM 2012 R2 with several Run PowerShell Script tasks.  Most of them run fine, but I am having trouble with the one I need to pass parameters to.
    The parameters I need to pass are:
    -ComputerOU "ou=All Workstations,dc=contoso,dc=com" -GroupDN "cn=Group1,ou=All Groups,dc=contoso,dc=com"
    I have that line (with actual DNs) entered in Parameters of the task.
    But when the script runs on the target machine, the values of the parameters in the script are truncated at the spaces.  $ComputerOU is set to "ou=All" and $GroupDN is set to "cn=Group1,ou=all"
    What syntax should I be using the Parameters field of the Task in order to properly pass PowerShell parameter string values that include spaces?
    Tim Curwick
    MadWithPowerShell.com

    Thank you, TC, but I am not calling the parameters from within PowerShell.
    The parameters are in the settings of a task sequence task to be used by the task to launch a script.  The syntax I am using would be correct for use within PowerShell or from a command line or batch script, but SCCM appears to be doing some parsing
    before or while it is passing them to the script, possibly dropping the quotes which causes mishandling of the spaces in the string values.
    Historically, it is always challenging to give one application parameters to pass to another application, and the required syntax can get quite tricky when the two application handle quotes or spaces differently, or when the parent application wants to parse
    something intended to be passed on as is to the child application.
    I'm sure someone has already figured out what the syntax needs to be for doing this with an SCCM 'Run PowerShell Script" task, it's just one of those issues that is hard to Google effectively.
    Any other ideas?
    Tim Curwick
    MadWithPowerShell.com

Maybe you are looking for

  • How to create Business Partners (in Person category) from Customer Accounts

    Hi all In ECC 6.0, I am creating Business Partners (Master Tenant w Customer Account) from 'employee' Customer Accounts and the system is defaulting to the 'Organization' category. Does anyone know how to configure it so that Business Partners are cr

  • Hi GIRU,How to check workflow status in a database

    Hi GURU, I am a DBA one user asked me to chke the workflow status for om order line in database.Any body help me how to check the status of workflow om order line in database.

  • Code Execution Visable During Start Up/ Shut Down

    I am pretty new to Macs, but I have implemented them into my corporate network over the last year, and finally I was able to get a new intel iMac for home use! On my new intel iMac, I see the process of Code Executing during start up and shut down. I

  • How can I get rid of "Jagged Edges" on the text in .jpg/.psd file in FCP?

    Hi guys, I am running FCP5.1 and I have a still image (.jpg) of a consumer product with the name of the product and the description on it. When I view it in the viewer or canvas, I see jagged edges around the name, description and the product. Even w

  • Error: SOAP is undefined

    Hello, I am attempting to use the SOAP object to access a WSDL definition and soap service. I have use the same out of the book code that appears frequently on the forums. However, my page throws "Error: SOAP is undefined" on PDF render time with onl