May 27, 2010 at 3:01 pm
I am trying to get the file name with a for each loop container and a script component but I receive an error on the script component: Below is the script:
Public Sub Main()
Dim FileName As String
Dts.Variables("User::FileName").Value = System.IO.Path.GetFileName(Dts.Variables("User::FileName").Value.ToString())
Dts.TaskResult = Dts.Results.Success
End Sub
May 28, 2010 at 2:01 am
What is the error that you get?
And why do you create a variable Filename that you don't use?
The following solution should work:
map the SSIS variable FileName in the For Each Loop to index 0 (see variable mappings).
Then, in your script component, use this code (make sure you add the variable FileName is a read-only variable in your script component/task):
Public Sub Main()
Dim FileName As String
FileName = Dts.Variables("User::FileName").Value.ToString()
Msgbox(Filename) 'To test it
Dts.TaskResult = Dts.Results.Success
End Sub
Note: if you use a script component, you should use Me.Variables.FileName to access the variable.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
May 28, 2010 at 4:47 am
This was removed by the editor as SPAM
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply