package configuration in script task

Posted on 2009-04-29
Last Modified: 2013-11-10
I written a script task that will check a ftp site for the existence of files in a directory. Now that I have it written, I want the scrpit task to read the package configuration file for the connection info instead of having it hard coded.

Is this possible to do ?
Public Sub Main()


            'Create the connection to the ftp server

            Dim cm As ConnectionManager = Dts.Connections.Add("FTP")

            Dim strFolders As String()

            Dim strFiles As String()

            Dim fileCount As Int32

            Dim vars As Variables

            fileCount = 0

            Dim fileName As String

            Dts.VariableDispenser.LockOneForWrite("FileExist", vars)

            'Set the properties like username & password

            cm.Properties("ServerName").SetValue(cm, "ftp.*********.net")

            cm.Properties("ServerUserName").SetValue(cm, "*********")

            cm.Properties("ServerPassword").SetValue(cm, "***********")

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

            'Connects to the ftp server

            ftp.UsePassiveMode = True


            ftp.SetWorkingDirectory("/Polling Processing/SV")

            ftp.GetListing(strFolders, strFiles)

            For Each fileName In strFiles

                If fileName.Contains("_sv.ZIP") Then

                    fileCount = fileCount + 1

                End If

                vars(0).Value = fileCount




        Catch ex As Exception

            Dts.TaskResult = Dts.Results.Failure

        End Try

		Dts.TaskResult = Dts.Results.Success

	End Sub

End Class

Open in new window

Question by:jorbroni
    LVL 9

    Expert Comment

    Why don't you just load the package configuration into a variable and access the variable inside the script?  I wouldn't go through the effort of reading the config file if you dont' have to.  Which you don't.
    LVL 22

    Expert Comment

    You can
      add the connection values as SSIS Variables and call it from the script.
      remove the connection properties from the script and add it directly to FTP connection manager.

    In both suggestion you can use SSIS Package configuration
    Follow the attached document I attached...
    LVL 22

    Accepted Solution

    You dont need anymore, but I gave you the answer.
    Dont delete the question for future users with the same issue.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now