Set FTP password in SSIS

In: SQL Server|SSIS


24 Nov 2008

Undoubtedly, you’re reading this because you’ve discovered that SQL Server Integration Services (as of SSIS 2008) will not allow you to set the password of an FTP connection through expressions. Fortunately, there is an easy workaround, that requires a simple Script Task. While not as simple as native expression support, it’s darn close. I’ve included C# code, but you may need to adapt to VB.Net if that’s your preferred flavor.

  1. Ensure a string variable is setup with the password. For this demo, I’m using the name, “FTPPassword”
  2. Add a Script Task to your package
  3. Edit the task
  4. On the Script page, click the elipsis for ReadOnlyVariables and check the box for User::FTPPassword.
  5. Click the “Edit Script…” button
  6. Change your entry point (Main, by default) to look like the below code. Save, close, and hit OK.
1
2
3
4
5
6
7
8
public void Main()
{
	ConnectionManager FTPConn;
	FTPConn = Dts.Connections["FTPServer"];
	FTPConn.Properties["ServerPassword"].SetValue(FTPConn, Dts.Variables["FTPPassword"].Value);
 
	Dts.TaskResult = (int)ScriptResults.Success;
}

A couple notes:

  • Ensure you update lines 4-5 to reflect the actual connection name. My example uses the name FTPServer.
  • Just to reiterate, my password is stored in the variable name FTPPassword. If yours is different make this change on line 5.

That’s it. Make sure you’ve got this task being executed before your actual FTP task and everything should work fine. Cheers!

  • Share/Bookmark

Comment Form

  • shiva ramani: good instruction. How to push data to MySQL from SQL 2005 [...]
  • Winkey: I've created a linked server for mysql successfully, and also can do Insert, Select. But when I try [...]
  • RaghuRam: Thanks a lot buddy it helped me to change the root password when I got the error trying to c [...]
  • Taylor Gerring: If you're on a 64-bit OS, did you run the 32-bit version of ODBC applet? Run: odbcad32 [...]
  • Taylor Gerring: If the issue is the guest sync'ing to the host, can't you just force time sync the host if you can't [...]


This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.