我想将包中的变量传递给脚本转换编辑器。如何将其添加到我的Row.Reference1下面?
这是我使用的脚本:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Row.Column1 = Tokenise(Row.Column0, "|", 1)
Row.Column2 = Tokenise(Row.Column0, "|", 2)
Row.Column3 = Tokenise(Row.Column0, "|", 3)
Row.Column4 = Tokenise(Row.Column0, "|", 4)
Row.Column5 = Tokenise(Row.Column0, "|", 5)
Row.Column6 = Tokenise(Row.Column0, "|", 6)
Row.Column7 = Tokenise(Row.Column0, "|", 7)
Row.Column8 = Tokenise(Row.Column0, "|", 8)
Row.Column9 = Tokenise(Row.Column0, "|", 9)
Row.Column10 = Tokenise(Row.Column0, "|", 10)
Row.Column11 = Tokenise(Row.Column0, "|", 11)
Row.Column12 = Tokenise(Row.Column0, "|", 12)
Row.Column13 = Tokenise(Row.Column0, "|", 13)
Row.Column14 = Tokenise(Row.Column0, "|", 14)
Row.Column15 = Tokenise(Row.Column0, "|", 15)
Row.Column16 = Tokenise(Row.Column0, "|", 16)
'Row.Reference1 = ???
End Sub
Private Function Tokenise(ByVal input As String, ByVal delimiter As String, ByVal token As Integer) As String
Dim tokenArray As String()
tokenArray = input.Split(delimiter.ToCharArray) 'Split the string by the delimiter
If tokenArray.Length < token Then 'Protect against a request for a token that doesn't exist
Return ""
Else
Return tokenArray(token - 1)
End If
End Function
End Class
答案 0 :(得分:1)
在脚本转换编辑器的“脚本”页面上,最后一部分是“自定义属性”。有两个属性:ReadOnlyVariables和ReadWriteVariables。设置适合您希望脚本引用的变量的逗号分隔列表的那些。
当您单击“编辑脚本”按钮时,您会发现在ComponentWrapper.vb中创建的Variables类现在具有包含变量名称的属性。只读变量将作为只读属性存在; ReadWrite变量将作为具有getter和setter的属性存在。
然后,您可以引用它们,例如Variables.TaskID
。