title: SSIS Script Component Write to Variable
body: <p>This is with SQL 2005.</p>
  
  <p>I have a script component inside a Data Flow Task. I would like to read from the input columns and write the data to a global user variable.</p>
  
  <p>I've set my input columns and added my global user variable as a ReadWriteVariable to the script component properties. </p>
  
  <p>Here is my code, I'm just trying to alter the value of the global user variable here, but its not working. When I write out the value of the variable in another task it still has its default value:</p>
  
  <pre><code>Imports System
  Imports System.Data
  Imports System.Math
  Imports Microsoft.SqlServer.Dts.Runtime
  Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
  Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
  
  Public Class ScriptMain
      Inherits UserComponent
      Dim updateSQL As String
  
      Public Sub Main()
          Dim vars As IDTSVariables90
  
          VariableDispenser.LockOneForWrite("SQL_ATTR_Update", vars)
          vars("SQL_ATTR_Update").Value = "Test"
          vars.Unlock()
      End Sub
  
  
      Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
          'updateSQL = Row.ITMID + Row.PRCCAT
      End Sub
  
  End Class
  </code></pre>
  
  <p>I have also tried with no luck: </p>
  
  <pre><code>Me.ReadWriteVariables("SQL_ATTR_Update").Value = "Test" 
  </code></pre>