1

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!

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

Comments

3

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

7 Comments

Yes, the addrMapPar field is set up only as an output column with the addrmap and addrpar fields as only input columns.
What you have posted looks fine, do you have any other code in there that might be causing the error? What about datatypes and Input/Output names, are they all correct?
The only other code (that also bombs) is data from another table that I'm doing the same thing with. The input/output names and datatypes should be correct. Could it be an issue that the output column is not also an input column? Or is there an Output0_ProcessOutputRow function I'm missing?
You won't need an Output function, and the output columns doesn't need to be an input column too. Have you tried deleting and re-creating the Script Component Task? I'm wondering if the BufferWrapper and ComponentWrapper code files have been amended or corrupted. Also, are you able to debug the script, either by using breakpoints or MessageBox statements?
I have deleted and recreated it, but no, I can't debug it and I don't get anything with MessageBox's either. I'll try to delete and recreate again and let you know...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.