2

In the code below I get the column name, I couldn't find a Value property in inputcolumn

I also need to get the value of the column, not only the name.

IDTSInput100 input = ComponentMetaData.InputCollection[0];

IDTSVirtualInput100 vinput = input.GetVirtualInput();

foreach (IDTSVirtualInputColumn100 inputcolumn in vinput.VirtualInputColumnCollection)
{
    strAll += inputcolumn.Name + ", " + Environment.NewLine;
}
Tassisto
  • 9,877
  • 28
  • 100
  • 157
  • i dont understand why using this code in script component? or it is script task? – Hadi Nov 05 '16 at 20:12
  • Because a script component allows you to transform data using my favorite programming language like c#. – Tassisto Nov 07 '16 at 07:43

1 Answers1

0

This code is vb.net but i think it is what you're looking for

Public Class ScriptMain

Inherits UserComponent

Private columns As Integer()

Public Overrides Sub PreExecute()

Dim input As IDTSInput90 = ComponentMetaData.InputCollection(0)

ReDim columns(input.InputColumnCollection.Count)

columns = Me.GetColumnIndexes(input.ID)

 System.Windows.Forms.MessageBox.Show(columns.Length.ToString())

End Sub

Public Overrides Sub ProcessInput(ByVal InputID As Integer, ByVal Buffer As Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer)



While Buffer.NextRow()

Dim values As New System.Text.StringBuilder

For Each index As Integer In columns

Dim value As Object = Buffer(index)

'If value Is Not Nothing Then

values.Append(value)

'End If

values.Append(",")

Next

'' TODO: Write line to destination here

System.Windows.Forms.MessageBox.Show(values.ToString())

End While

End Sub

End Class

Me.GetColumnIndexes() method can be created from your provided code.

Hadi
  • 36,233
  • 13
  • 65
  • 124