【发布时间】:2021-01-18 08:28:14
【问题描述】:
我在 SSIS 项目中遇到了一个大问题。
当我在 SSIS 本地机器中执行项目时,dtsx 运行良好,但是当我将它放入 SQL 代理作业时,它会抛出一个错误:
来源:文件夹中的文件?说明:调用的目标已引发异常。结束错误错误:2020-10-02 17:37:05.33 代码:0x00000001 源:脚本任务 1 描述:调用目标已引发异常。结束错误 DTExec:包执行返回 DTSER_FAILURE (1)。开始时间:17:37:01 结束时间:17:37:05 经过时间:3.687 秒。包执行失败。步骤失败。
文件夹中的源文件是一个脚本任务,代码如下:
Dim StrFolderArrary As String()
Dim StrFileArray As String()
Dim fileName As String
Dim RemoteDirectory As String
RemoteDirectory = Dts.Variables("User::ftp_masks").Value.ToString()
Dim cm As ConnectionManager = Dts.Connections("FTP Connection Manager") 'FTP connection manager name
Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))
Try
ftp.Connect() 'Connecting to FTP Server
ftp.SetWorkingDirectory(RemoteDirectory) 'Provide the Directory on which you are working on FTP Server
ftp.GetListing(StrFolderArrary, StrFileArray) 'Get all the files and Folders List
'If there is no file in the folder, strFile Arry will contain nothing, so close the connection.
If StrFileArray Is Nothing Then
MessageBox.Show(Dts.Variables("User::FileExistsFlg").Value.ToString())
Dts.Variables("User::FileExistsFlg").Value = 0
ftp.Close()
'If Files are there, Loop through the StrFileArray arrary and insert into table
Else
For Each fileName In StrFileArray
MessageBox.Show(fileName)
Dts.Variables("User::files").Value = fileName
MessageBox.Show(Dts.Variables("User::files").Value.ToString())
If fileName = Dts.Variables("User::files").Value.ToString() Then
Dts.Variables("User::FileExistsFlg").Value = 1
MessageBox.Show(Dts.Variables("User::FileExistsFlg").Value.ToString())
End If
Next
Dts.TaskResult = ScriptResults.Success
ftp.Close()
End If
MessageBox.Show("End try")
Catch ex As Exception
MessageBox.Show("Catch")
Dts.Events.FireError(0, "My File Task", ex.Message, String.Empty, 0)
MessageBox.Show("Stack Trace: " & vbCrLf & ex.StackTrace)
Throw New ApplicationException("Something happened :(", ex)
'Dts.TaskResult = ScriptResults.Failure
Finally
' This line executes whether or not the exception occurs.
MessageBox.Show("in Finally block")
End Try
'
' Add your code here
'
Dts.TaskResult = ScriptResults.Success
有人可以帮助我吗? 如何查看具体错误?
感谢您的宝贵时间。
【问题讨论】:
标签: sql-server ssis integration