Get filename from connection manager with VB.net

  • I have a flat file that is set up in a connection manager. I need to read the first line of the file and get some information from it for my SSIS routine. So I have a Script Task where I use VB.net to read and move the information to a global variable for later use. I set up another global variable with the flat file name in it for the VB.net code routine to know what file to read. This name matches what is in the connection manager. I would like to be able to reference the filename in the connection manager instead of a global variable, so that when I change the connection manager to a test file the VB.net automatically gets the new test file name without me having to change the global variable as well. Does anyone know of way to do this?

  • You can access the connection manager items using Dts.Connections collection. Try following to get the path of a File connection nanmed 'FileConnectionName'

    Dts.Connections.Item("FileConnectionName").ConnectionString

    You can thin use this to open and read file from the connection.

    HTH

  • Thank you very much that will help a lot. I just babble at VB.net and was wondering, do you know where all of the DTS. information is documented? I use the DTS.Variables and now know of the DTS.Connections, if I knew where it was documented I could just read and not bother the forums. Thank you again.

  • Follow the link below for a quick intro to Interacting with the Package in the Script Task

    http://msdn.microsoft.com/en-us/library/ms135952.aspx

    HTH

  • That link is great. Thank you again for all of your help in this matter.

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

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