In DTS I used workflow ActiveX script to determine File Existence and depends on the result run one of the following tasks.
I had a global variable with FileName. Then in ActiveX script I had script like this:
Function Main()
Dim oFSO, sFileName
sFilename = DTSGlobalVariables("FileName").Value
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Check for file and return appropriate result
If oFSO.FileExists(sFilename) Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
Set oFSO = Nothing
End Function
Moving to 2005 SSIS I need to create ScriptTask instead.
I created Precedence Constraint depends on value of FileFound variable. FileName and FileFound are global for SSIS variables.
My script looks like:
Dim FileFound As String
Dim sFileName As String
sFileName = Dts.Variables.Item ("FileName").Value.ToString()
If File.Exists(sFileName) Then
Dts.Variables("FileFound").Value = "1"
MsgBox(FileFound)
Else
Dts.Variables("FileFound").Value = "0"
MsgBox(FileFound)
End If
MsgBox(FileFound)
Dts.TaskResult = Dts.Results.Success
Executing this task I got error: when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
at Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
Why can not I get sFileName from Global Variables the way I am doing?
Please help.
I had a global variable with FileName. Then in ActiveX script I had script like this:
Function Main()
Dim oFSO, sFileName
sFilename = DTSGlobalVariables("FileName").Value
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Check for file and return appropriate result
If oFSO.FileExists(sFilename) Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
Set oFSO = Nothing
End Function
Moving to 2005 SSIS I need to create ScriptTask instead.
I created Precedence Constraint depends on value of FileFound variable. FileName and FileFound are global for SSIS variables.
My script looks like:
Dim FileFound As String
Dim sFileName As String
sFileName = Dts.Variables.Item ("FileName").Value.ToString()
If File.Exists(sFileName) Then
Dts.Variables("FileFound").Value = "1"
MsgBox(FileFound)
Else
Dts.Variables("FileFound").Value = "0"
MsgBox(FileFound)
End If
MsgBox(FileFound)
Dts.TaskResult = Dts.Results.Success
Executing this task I got error: when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
at Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
Why can not I get sFileName from Global Variables the way I am doing?
Please help.