jorbroni
asked on
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 ?
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
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.
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.