如何在SSIS中获取脚本组件中的列值?

时间:2016-11-05 04:51:17

标签: c# ssis transform

在下面的代码中,我得到了列名,我在 inputcolumn

中找不到Value属性

我还需要获取列的值,而不仅仅是名称。

{{1}}

1 个答案:

答案 0 :(得分:0)

此代码是vb.net,但我认为这是您正在寻找的

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()方法。