Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1349
  • Last Modified:

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

0
jorbroni
Asked:
jorbroni
  • 2
1 Solution
 
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
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now