我正在尝试从 SSIS 包中的平面文件中为变量赋值。我正在使用的脚本如下
#Region "Imports"
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
#End Region
' This is the class to which to add your code. Do not change the name, attributes, or parent
' of this class.
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute()> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
Dim StartDate As String
Dim FinishDate As String
Public Overrides Sub PreExecute()
MyBase.PreExecute()
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
Me.ReadWriteVariables("StartDate").Value = StartDate
Me.ReadWriteVariables("FinishDate").Value = FinishDate
End Sub
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
StartDate = Row.StartDate
FinishDate = Row.FinishDate
End Sub
End Class
我遇到的问题是,有时平面文件中的字段可能为空白,当它们为空白时,我收到错误消息:
分配给变量“User::StartDate”的值的类型与当前变量类型不同。变量在执行期间可能不会改变类型。变量类型是严格的,除了 Object 类型的变量。
有没有人有任何想法可能导致错误?