Assign value to SSIS Script Component new Output Column

别说谁变了你拦得住时间么 提交于 2019-12-12 23:04:54

问题


I'm sure this is a simple issue, but I'm trying to combine 2 columns into a new output column, but have not had any luck with it. Each time I get an 'Object reference not set to an instance of an object.' error

Here is my code:

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Public Class ScriptMain
    Inherits UserComponent

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        '
        ' Add your code here
        '
        Dim tmpStr As String
        tmpStr = ""
        If Not IsNumeric(Row.addrmap.ToString) Then
            tmpStr = Row.addrmap.ToString.Substring(Row.addrmap.ToString.Length - 2, 1)
            tmpStr = Row.addrmap.ToString.Remove(Row.addrmap.ToString.Length - 2, 1).PadLeft(3, CChar("0")) & " " & tmpStr.PadLeft(3, CChar("0")) & " " & Row.addrpar.ToString

        Else
            tmpStr = Row.addrmap.ToString.PadLeft(3, CChar("0")) & " " & "000 " & Row.addrpar.ToString
        End If
        Row.addrMapPar = tmpStr
    End Sub

End Class

Thanks for the help!


回答1:


I figured out the issue! It had to do with NULLS in the data. I didn't provide the data, I was just parsing through it and found that there were some NULLs I didn't know about.

To fix it, I used:

If Row.addrmap_IsNull = False and Row.addrpar_IsNull = False Then
...
End If



回答2:


Have you added the new output column to the Inputs And Outputs property pane of the Script Component Task?



来源:https://stackoverflow.com/questions/5223822/assign-value-to-ssis-script-component-new-output-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!