package configuration in script task

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()
        Try
            '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.Connect()
            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
                vars.Unlock()
 
            Next
            ftp.Close()
        Catch ex As Exception
            Dts.TaskResult = Dts.Results.Failure
        End Try
		Dts.TaskResult = Dts.Results.Success
	End Sub
 
End Class

Open in new window

LVL 1
jorbroniAsked:
Who is Participating?
 
PedroCGDCommented:
You dont need anymore, but I gave you the answer.
Dont delete the question for future users with the same issue.
Regards,
Pedro
0
 
HwkrangerCommented:
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.
0
 
PedroCGDCommented:
You can
  add the connection values as SSIS Variables and call it from the script.
  or
  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...
Helped?
Pedro
www.pedrocgd.blogspot.com
POTS-EX02-EN.doc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.