-1

I'm trying to learn how to use script component. I'm trying to take a value, 'Gender', and then check to see whether it is "M" or "F". If it is M then change value to G and if F then change value to L. My input column is gender and my output column is genderChange I'm just going to have it print to a flat file. I'm aware that there are transformations already built into SSIS but I really want to use script component.

This is my code that I have

Dim arr() As String = Row.Gender.Split(","c)
        Dim iReadingCount As Integer = 1
         Dim convertVal As String = " "


        For i As Integer = 0 To arr.Length - 1
            With Output0Buffer


                .AddRow()

                convertVal = Convert.ToString(Row.Gender)
                If (convertVal Is "M") Then
                     .genderChange = "G"
                  End If
                If (convertVal Is "F") Then
                    .genderChange = "L"
                 End If

                 iReadingCount += 1
            End With
        Next

Thank you for your help

crack3r
  • 49
  • 1
  • 5
  • What you don't specify is that you are creating an asynchronous component (1 input row != 1 output row). The `Gender` is going to be a CSV ("M,M,F") and for each value in that list, your desire is to create a row and have the value translated. Is this an accurate assessment of your intention? – billinkc May 14 '13 at 04:20
  • Yeah,that's what I was trying to do. – crack3r May 14 '13 at 14:07

1 Answers1

0

For one thing, the vb.net syntax is wrong here:

If (convertVal Is "M") Then
                     .genderChange = "G"
                  End If
                If (convertVal Is "F") Then
                    .genderChange = "L"
                 End If

One correct way to do this would be:

If convertVal.Equals("M") Then
                     .genderChange = "G"
                  End If
                If convertVal.Equals("F") Then
                    .genderChange = "L"
                 End If
Tab Alleman
  • 31,483
  • 7
  • 36
  • 52