如何在 SSIS 的脚本组件中获取列值? [英] How can I get the column Value in Script Component in SSIS?

查看:26
本文介绍了如何在 SSIS 的脚本组件中获取列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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;
}

推荐答案

这段代码是 vb.net 但我认为这正是你要找的

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() 方法可以从您提供的代码中创建.

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

这篇关于如何在 SSIS 的脚本组件中获取列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆