Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Exception from HRESULT: 0xC001602A while running ssis pacakge using ftp

$
0
0

Hi,

Can anyone please guide me with the above error.Below is the script i am using to connect to the ftp server. i get the above error. If i try to connect using Filezilla i am able to connect.

' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic 2008.
' The ScriptMain is the entry point class of the script.

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

<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

    Enum ScriptResults
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum


    ' The execution engine calls this method when the task executes.
    ' To access the object model, use the Dts property. Connections, variables, events,
    ' and logging features are available as members of the Dts property as shown in the following examples.
    '
    ' To reference a variable, call Dts.Variables("MyCaseSensitiveVariableName").Value
    ' To post a log entry, call Dts.Log("This is my log text", 999, Nothing)
    ' To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, True)
    '
    ' To use the connections collection use something like the following:
    ' ConnectionManager cm = Dts.Connections.Add("OLEDB")
    ' cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"
    '
    ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    ' 
    ' To open Help, press F1.

    Public Sub Main()
        '
        ' Add your code here
        '
        Dim Files As New System.Collections.Generic.List(Of String)
        Dim cm As ConnectionManager = Dts.Connections.Add("FTP")
        Dim strFolders As String()
        Dim strFiles As String()
        Dim fileCount As Int32
        fileCount = 0
        Dim fileName As String
        Dim aList As New ArrayList()
        Dim strArray As String()

        'Set the properties like username & password
        Try
            cm.Properties("ServerName").SetValue(cm, "172.19.232.132")
            cm.Properties("ServerUserName").SetValue(cm, "username")
            cm.Properties("ServerPassword").SetValue(cm, "password")
            cm.Properties("ServerPort").SetValue(cm, "21")

            Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))

            'Connects to the ftp server
            MessageBox.Show("Start Conneted")
            ftp.Connect()
            ftp.SetWorkingDirectory("/home/sam/log/test")


            MessageBox.Show("Conneted")

            ftp.GetListing(strFolders, strFiles)
            'Else

            ' End If
            For Each fileName In strFiles
                fileCount = fileCount + 1
                If (fileName.Contains("TFILE")) Then
                    aList.Add(fileName + ".dat")


                End If

            Next


            'strFiles.CopyTo(strArray, 110)
            aList.ToString()
            strArray = DirectCast(aList.ToArray(GetType(String)), String())

            ftp.ReceiveFiles(strFiles, "D:\FTP\Data\", True, False)
            'End While
            ' Next

            ftp.Close()
            ' GetFiles(D:\FTP\Data\", Files)

        Catch ex As Exception
            MessageBox.Show(ex.Message)


            Dts.TaskResult = ScriptResults.Failure

        End Try

        Dts.TaskResult = ScriptResults.Success
        Dts.TaskResult = ScriptResults.Success
    End Sub

End Class


rr


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>