I have a script component in a data flow task to apply some logic to records and output to a different table. It all works fine until I get to records which contain Chinese or Japanese characters. It seems to transform the characters to ??????
I'm running SSIS 2008 R2. Below is the code. It works perfectly for non Asian character strings. Is there another connection type I should be using when dealing with unicode fields?
' Microsoft SQL Server Integration Services Script Component
' Write scripts using Microsoft Visual Basic 2008.
' ScriptMain is the entry point class of the script.
Imports System
Imports System.Data
Imports System.Math
Imports System.String
Imports System.Data.SqlClient
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
Dim connMgr As IDTSConnectionManager100
Dim sqlConn As SqlConnection
Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
connMgr = Me.Connections.HuthwaiteDMConnection
sqlConn = CType(connMgr.AcquireConnection(Nothing), SqlConnection)
End Sub
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim iCols As Int16
Dim i As Int16
Dim strQuery As String
Dim strColG As String
strQuery = "Select Verify_email_Address, ProgramID, Organization, AssessKey, Exam_Name, Exam, Attempts, ISNULL(MaxAttempt,0), ISNULL(MinAttempt,0), Start_Date, Finish_Date, LoadDate, Total_Points"
iCols = Row.GroupCount
For i = 1 To iCols
Select Case i
Case 1
If IsNullOrEmpty(Row.G1) = False Then StrColG = Row.G1.ToString
If IsNullOrEmpty(Row.G1) = False Then strQuery = strQuery & " ," & strColG & " as G1"
Case 2
If IsNullOrEmpty(Row.G2) = False Then strColG = Row.G2.ToString
If IsNullOrEmpty(Row.G2) = False Then strQuery = strQuery & " ," & strColG & " as G2"
Case 3
If IsNullOrEmpty(Row.G3) = False Then strColG = Row.G3.ToString
If IsNullOrEmpty(Row.G3) = False Then strQuery = strQuery & " ," & strColG & " as G3"
Case 4
If IsNullOrEmpty(Row.G4) = False Then strColG = Row.G4.ToString
If IsNullOrEmpty(Row.G4) = False Then strQuery = strQuery & " ," & strColG & " as G4"
Case 5
If IsNullOrEmpty(Row.G5) = False Then strColG = Row.G5.ToString
If IsNullOrEmpty(Row.G5) = False Then strQuery = strQuery & " ," & strColG & " as G5"
Case 6
If IsNullOrEmpty(Row.G6) = False Then strColG = Row.G6.ToString
If IsNullOrEmpty(Row.G6) = False Then strQuery = strQuery & " ," & strColG & " as G6"
Case 7
If IsNullOrEmpty(Row.G7) = False Then strColG = Row.G7.ToString
If IsNullOrEmpty(Row.G7) = False Then strQuery = strQuery & " ," & strColG & " as G7"
Case 8
If IsNullOrEmpty(Row.G8) = False Then strColG = Row.G8.ToString
If IsNullOrEmpty(Row.G8) = False Then strQuery = strQuery & " ," & strColG & " as G8"
Case 9
If IsNullOrEmpty(Row.G9) = False Then strColG = Row.G9.ToString
If IsNullOrEmpty(Row.G9) = False Then strQuery = strQuery & " ," & strColG & " as G9"
Case 10
If IsNullOrEmpty(Row.G10) = False Then strColG = Row.G10.ToString
If IsNullOrEmpty(Row.G10) = False Then strQuery = strQuery & " ," & strColG & " as G10"
End Select
Next
strQuery = strQuery & " From Corrected_PostAssessment where ProgramID = " & "'" & Row.ProgramID & "'"
Dim command As New SqlCommand(strQuery, sqlConn)
Dim reader As SqlDataReader = command.ExecuteReader
While reader.Read()
With Output0Buffer
.AddRow()
.VerifyemailAddress = reader(0)
.ProgramID = Row.ProgramID
.Organization = reader(2)
.AssessKey = reader(3)
.ExamName = reader(4)
.Exam = reader(5)
.Attempts = reader(6)
.MaxAttempt = reader(7)
.MinAttempt = reader(8)
.StartDate = reader(9)
.FinishDate = reader(10)
.LoadDate = reader(11)
.TotalPoints = reader(12)
If Row.GroupCount >= 1 Then .G1 = reader(13)
If Row.GroupCount >= 2 Then .G2 = reader(14)
If Row.GroupCount >= 3 Then .G3 = reader(15)
If Row.GroupCount >= 4 Then .G4 = reader(16)
If Row.GroupCount >= 5 Then .G5 = reader(17)
If Row.GroupCount >= 6 Then .G6 = reader(18)
If Row.GroupCount >= 7 Then .G7 = reader(19)
If Row.GroupCount >= 8 Then .G8 = reader(20)
If Row.GroupCount >= 9 Then .G9 = reader(21)
If Row.GroupCount >= 10 Then .G10 = reader(22)
End With
End While
reader.Close()
End Sub
End Class
Any insight will be greatly appreciated.
Regards,
Bill Webster