2012-07-31 180 views
0

不知道我在做什麼錯在這裏 - 我試圖生成一個變量,然後我會傳遞給FTP任務。SSIS寫變量腳本任務

在腳本任務中,我設置了變量ReadWrite = User :: WildCard。目前,User :: WildCard變量的字符串值爲「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

在你的代碼中,我沒有看到LockForWrite的任何地方。我想你需要這樣才能回寫一個變量。 Here是來自Jaime Thomson博客的一個很好且簡單的例子。希望這可以幫助。