Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Script Task for connecting and FTP'ing files to another server

$
0
0

Hi,

Following the examples in this topic I have attempted to get the FTP to work in my SSIS package with no luck.   If I use the FTP Task in SSIS and setup the connection, when I execute that it works fine.  The problem I'm having like the others is that the FTP Task does not store the password.  So, in my search to find another method of creating the FTP connection I came across this thread.  At first I tried creating a dsconfig file that stored the information for the fTP connection but that didn't work.  Next and with more success I used the following code however it too gives me a 550 access denied error which to me doesn't make sense since I can use the FTP Task wizard with the same parameters and it works.  Below is my code:

PublicSub Main()Try'Create the connection to the ftp serverDim cm As ConnectionManager = Dts.Connections.Add("FTP Connection Manager")'Set the properties like username & password
            cm.Properties("ServerName").SetValue(cm,"mydestinationservernameHere")
            cm.Properties("ServerUserName").SetValue(cm,"mydestinationUsernamehere")
            cm.Properties("ServerPassword").SetValue(cm,"mydestinationuserpasswordhere")
            cm.Properties("ServerPort").SetValue(cm,"21")
            cm.Properties("Timeout").SetValue(cm,"0")'The 0 setting will make it not timeout
            cm.Properties("ChunkSize").SetValue(cm,"1000")'1000 kb
            cm.Properties("Retries").SetValue(cm,"1")'create the FTP object that sends the files and pass it the connection created above.Dim ftp As FtpClientConnection =New FtpClientConnection(cm.AcquireConnection(Nothing))'Connects to the ftp server

            ftp.Connect()'Build a array of all the file names that is going to be FTP'ed (in this case only one file)Dim files(0)AsString

            files(0)="thesourcefilelocation"'ftp the file 'Note: I had a hard time finding the remote path directory. I found it by mistake by creating both the FTP connection and task in the SSIS package and it defaulted the remote path setting in the FTP task.

            ftp.SendFiles(files,"the destination file location for the destination user which is /",True,False)' the True makes it overwrite existing file and False is saying that it is not transferring ASCII

            ftp.Close()Catch ex As Exception
            Dts.TaskResult = Dts.Results.FailureEndTryEndSub

I don't know why I'm getting the 550 access denied error. I really need some help with this.

thanks


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>