using script component
Hi ... I have a excel source and i want to validate each column on its datatype and data using script component while loading into temp table.
I have to check the data using script component and load good and bad data to seperate tables.
I have like 10 columns for ex: Id column should be integer, i have to check whether Id column is string or integer like that i have ~10 columns.
And also need to add some custom validation
I am not good with C# or .net, Please help me on this
June 14th, 2011 10:58am
Hi...I am using this script component after the excel source .
From excel source records are going into Script component but its not producing any out put rows.
In the script : FileName = Me.Variables.SourcePath (The source path is variable name which i have pointed into source file )
Please help me on this.
' Microsoft SQL Server Integration Services user script component
' This is your new script component in Microsoft Visual Basic .NET
' ScriptMain is the entrypoint class for script components
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports System.IO
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public Sub CreateNewOutputRows()
Dim oFile As File
Dim oRead As StreamReader
Dim LineIn As String
Dim RecordType As String
Dim FileName As String
Dim ErrorDesc As String
Dim RecordCount As Integer
Dim Art_File As String
Dim Code As String
Dim ENGLISH As String
Dim Definition As String
Dim GERMAN As String
Dim FRENCH As String
Dim SPANISH As String
Dim ITALIAN As String
Dim DANISH As String
Dim EU_PORTUGUESE As String
Dim NEDERLANDS As String
Dim BRAZILIAN_PORTUGUESE As String
Dim SWEDISH As String
Dim POLISH As String
Dim TURKISH As String
Dim Chinese As String
Dim IsGoodRecord As Boolean
FileName = Me.Variables.SourcePath
RecordCount = 0
Try
oRead = oFile.OpenText(FileName)
While oRead.Peek <> -1
'LineIn = oRead.ReadLine()
ErrorDesc = ""
If Art_File = "" Or Code = "" Then
IsGoodRecord = False
Else
IsGoodRecord = True
End If
OutputBuffer.AddRow()
OutputBuffer.Artfile = Art_File
OutputBuffer.Code = Code
OutputBuffer.ENGLISH = ENGLISH
OutputBuffer.Definition = Definition
OutputBuffer.GERMAN = GERMAN
OutputBuffer.FRENCH = FRENCH
OutputBuffer.SPANISH = SPANISH
OutputBuffer.ITALIAN = ITALIAN
OutputBuffer.DANISH = DANISH
OutputBuffer.EUPOTUGUESE = EU_PORTUGUESE
OutputBuffer.NEDERLANDS = NEDERLANDS
OutputBuffer.BRAZILIANPORTUGUESE = BRAZILIAN_PORTUGUESE
OutputBuffer.SWEDISH = SWEDISH
OutputBuffer.POLISH = POLISH
OutputBuffer.TURKISH = TURKISH
OutputBuffer.Chinese = Chinese
OutputBuffer.IsGoodRecord = IsGoodRecord
End While
Catch e As Exception
Me.ComponentMetaData.FireError(2, "script source", e.Message, "", 1, True)
Finally
oRead.Close()
End Try
End Sub
End Class
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2011 8:20am
Is that clear???
Or you want any input from me.
In that i have added just one condition on columns.Its not throwing any error but it is not generating any output.
June 15th, 2011 10:34am