retrieve Filename via Script

  • Hi,

    i need to get a substring of the filename to add it to the dataflow.

    So I added a script task and edited it as follows:

    Public Sub Main()

    Dim myFlatFileConnection As String

    myFlatFileConnection = DirectCast(Dts.Connections("src_instrument").AcquireConnection(Dts.Transaction), String)

    'MsgBox(myFlatFileConnection)

    Dts.Variables("quelle").Value = myFlatFileConnection

    Dts.TaskResult = Dts.Results.Success

    End Sub

    On Runtime I get this error:

    The connection "src_instrument" is not found. This error is thrown by Connections collection when the specific connection element is not found.

    But my connection in the package has the name "src_instrument"

    Do you know the cause of the error?

    Thank you

    Tobias

  • did you try the "for each loop" container to get this doen (in stead of a script task)

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • The foreach loop was a good idea. With this task i got the filename.

    Thank you

  • Using for each loop it one of the best way to go through filename.

    But I am just curious about using connection in script.

    did you use the servername.ConnectionName?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply