Tuesday, August 26, 2014

How to access the parameter (Read and Write) in the SSIS script task



How to access the parameter (Read and Write) in the SSIS script task

For example, my variable names
ReadOnlyvariables  – FilePath
WriteOnlyVairables – LocalFilePath

If I used the VB.Net application means the calling variable in the below format

Public Sub Main()
Try
            Dts.Variables("User::LocalFilePath").Value =
                                                                                Dts.Variables("User::FilePath").Value
            MsgBox("VB.Net Format: " & Dts.Variables("User::LocalFilePath").Value.ToString())
        Catch e As Exception
            MessageBox.Show("VB.Net Format: Something went wrong. Error: " + e.Message)
        End Try

        Dts.TaskResult = ScriptResults.Success
End Sub
 
Suppose C# application means

public void Main()
{
                try
{
// Fill local variable with value from parent variable
Dts.Variables["User::LocalFilePath"].Value =   
Dts.Variables["User::FilePath"].Value;
              MessageBox.Show("C# Format: " +                    
   Dts.Variables["User::LocalFilePath"].Value.ToString());
            }
        catch (Exception e)
        {
                MessageBox.Show("C# Format: Something went wrong. Error: " + e.Message);
            }
           
        Dts.TaskResult = (int)ScriptResults.Success;
        }