6 ssis
在一个Script Task,我试图从网络位置检索文件,并将FTP该文件检索到非现场位置
FTP Connection并测试了它的设置和工作创建了三个变量
创建了一个Script Task并添加了vb代码......
'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
Run Code Online (Sandbox Code Playgroud)错误:无法在集合中找到该元素.当您尝试在执行包期间从容器上的集合中检索元素并且该元素不存在时,会发生此错误.
所以我已经注释掉了,发现错误是在检索变量值时产生的,但我不知道这里有什么不对
Dim remotePath As String = Dts.Variables("FTPFilePath").Value.ToString
Run Code Online (Sandbox Code Playgroud)
我尝试了多个变量检索,并且都得到了相同的错误.有人看错了吗?
Kei*_*ler 16
两件事情:
Dts.Variables["User::RemotePath"].Value| 归档时间: |
|
| 查看次数: |
15654 次 |
| 最近记录: |