【发布时间】:2021-12-02 12:15:36
【问题描述】:
全部,
SSIS - 尝试使用 Visual Basic 编程语言中的脚本任务建立 ftp 连接以将文件上传到 ftp 服务器,但我遇到了问题。我在搜索中没有找到类似的东西,因此非常感谢您的帮助。
[连接管理器“FTP”] 错误:请求的 FTP 操作发生错误。详细错误说明:220
控制通道需要 550 SSL/TLS
代码:
Public Sub Main()
'
' Add your code here
'
Try
Dim cm As ConnectionManager
cm = Dts.Connections("FTP")
'Set the properties like username & password
cm.Properties("ServerName").SetValue(cm, "ftps.example.com")
cm.Properties("ServerUserName").SetValue(cm, "username")
cm.Properties("ServerPassword").SetValue(cm, "password")
cm.Properties("ServerPort").SetValue(cm, "port")
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) As String
files(0) = "C:\ local path file"
'ftp the file
ftp.SendFiles(files, "/remote path", 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 = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Try
【问题讨论】:
-
我没有找到有关这些 FTP 连接属性的任何文档。无论如何,一旦你编写了所有代码,为什么不使用标准的 .NET
FtpWebRequest和它的EnableSsl = True?见Upload file to FTP site using VB.NET。
标签: ssis ftp ftps script-task