SSIS写入变量脚本任务

时间:2012-07-31 15:05:55

标签: vb.net ssis

不确定我在这里做错了什么 - 我正在尝试生成一个变量,然后我将传递给FTP任务。

在Script Task中,我设置了变量ReadWrite = User :: WildCard。目前,User :: WildCard变量的String值为“test.csv”。此脚本应该今天将字符串值重命名为“/forecasts/forecast_20120730.csv”。截至目前,该脚本已成功运行,但该变量未写入。

#Region "Imports"
Imports System
Imports System.Data
Imports System.Collections
Imports System.Math    
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
#End Region

'ScriptMain is the entry point class of the script.  Do not change the name, attributes,
'or parent of this class.
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

    'This method is called when this script task executes in the control flow.
    'Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    'To open Help, press F1.

    Enum ScriptResults
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum

    Public Sub Main()

        Dim FilePart As String

        FilePart = Format(Now, "yyyyMMdd")

        Dts.Variables("WildCard").Value = "/forecasts/forecast_" & FilePart & "*.csv"
        Dts.TaskResult = ScriptResults.Success

    End Sub

End Class

1 个答案:

答案 0 :(得分:1)

在你的代码中,我在任何地方都看不到LockForWrite。我认为你需要这样才能回写变量。 Here是Jaime Thomson博客关于如何做到这一点的一个很好的简单例子。希望这可以帮助。