title: SSIS Script Component - Iterate Through Columns with NULL Values
body: <p>I am using the following .NET code to iterate through all input columns to create a HashByte value of the columns to then determine if the row has been updated.</p>
  
  <p>The script works fine until a column has a NULL value. How can I code around this without using a TRY CATCH block?</p>
  
  <pre><code>Imports System.Text
  Imports System.Reflection
  Imports System.Security.Cryptography
  
  Private sha As SHA256 = New SHA256CryptoServiceProvider() 'used To create the SHA256 hash
  
  Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
  
      Try
  
          ' create hashbyte column to identify if row has changed
  
          Dim concat As StringBuilder = New StringBuilder("")
  
          ' loop over all the input columns of the buffer row 
  
          For Each col As PropertyInfo In Row.GetType().GetProperties()
  
              If Not col.Name.ToLower.EndsWith("isnull") AndAlso Not col.Name.ToLower.Equals("hash") Then
                  MsgBox(col.Name.ToLower)
                  If col.GetValue(Row, Nothing) Is Nothing Then
                      concat.Append("")
                  Else
                      concat.Append(Convert.ToString(col.GetValue(Row).ToString()))
                  End If
  
                  concat.Append("|")
              End If
  
          Next
  
          Dim sHashBytes As String = concat.ToString().Remove(concat.ToString().Length - 1) ' remove the last character of the string
          Dim bHashBytes As Byte() = sha.ComputeHash(System.Text.UnicodeEncoding.Unicode.GetBytes(sHashBytes))
          Dim sb As StringBuilder = New StringBuilder("")
  
          For i As Integer = 0 To bHashBytes.Length - 1
              sb.Append(bHashBytes(i).ToString("X2"))
          Next
  
          Row.Hash = "0x" &amp; sb.ToString()
  
      Catch ex As Exception
          MsgBox(ex.ToString)
      End Try
  End Sub
  </code></pre>
  
  <p>Thanks, Greg</p>