SSIS FTP Task – Code to set the password

If you are having problems setting the password to the FTP task in SSIS, then the likelyhood is you are trying to use an expression to set it (can’t be done); you are being caught out by clicking [OK] (finger trouble) in the FTP connection manager editor, or you are struggling with the encryption settings (a long subject) for your package.

I don’t want to enter into discussion here on the encryption level you use (I will discuss that in another post some other time), merely this post just contains some simple code that you can use to set the password with a script component placed before the FTP task.

Amazon Link: Hands-On Microsoft SQL Server 2005 Integration Services

It takes the value of a variable “FTPPassword” and uses it to set the FTP connection manager property “ServerPassword”.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain

Public Sub Main()

Dim FTPConnectionManager As ConnectionManager

'Set variable to an existing connection manager
FTPConnectionManager = Dts.Connections("FTP Server")

'Set connection manager property "ServerPassword"
FTPConnectionManager.Properties("ServerPassword").SetValue(FTPConnectionManager, Dts.Variables("FTPPassword").Value)

Dts.TaskResult = Dts.Results.Success

End Sub

End Class



3 thoughts on “SSIS FTP Task – Code to set the password”

  1. Just wanted to say thanks for this bit of code. I was able to implement it within an existing script task I had.

    It resolved the password issue I had that didn’t occur within BIDS. It’s an annoying little gotcha and thankfully it only took a few minutes to resolve.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.