k i think i have spent way to long on this one. So here is what i am doing. In a ScriptTask I am trying to retrieve a file from a networked location and FTP that file to an offsite location.
- In SSIS i created the FTP Connection and tested that it is setup and works. Created Three Variables (because i tested this a million ways)
- variable 1. FullPathName = \ftpservercsc\\\Filename.txt
- variable 2 FTPFilePath = \ftpservercsc\\\
variable 3 FTPFileName = Filename.txt
Created a script Task and added the vb code as such
'Get instance of the connection manager. Dim cm As ConnectionManager = Dts.Connections("FTP Connection Manager") Dim remotePath As String = Dts.Variables("FTPFilePath").Value.ToString 'create the FTP object that sends the files and pass it the connection created above. Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing)) 'Connect to the ftp server ftp.Connect() 'Set the path on the FTP server where dropping files 'ftp.SetWorkingDirectory("/Prequalify") 'set the remote directory Dim files(0) As String files(0) = Dts.Variables("FTPFileName").Value.ToString 'eg. File1.trg 'Send File ftp.SendFiles(files, remotePath, True, True) ' Close the ftp connection ftp.Close() 'Dts.Events.FireInformation(0, context, "File " + fileToGet + " retrieved successfully.", Nothing, Nothing, True) Dts.TaskResult = Dts.Results.Success
Error: The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
So i have commented out and found the error is generating on retrieving the variable value but i do not know what is incorrect here
Dim remotePath As String = Dts.Variables("FTPFilePath").Value.ToString
I have tried multiple variable retrievals and all get the same error. Anyone see anything wrong?