Database Reference
In-Depth Information
XML file) and access shared configuration resources that might be used by other, non-
SSIS parts of your data integration solution. The Script task is able to read and modify
package properties at runtime, including the variable values and all connection man-
ager properties.
Listing 17-9 provides sample code of a Script task that sets a connection manager's
ConnectionString at runtime.
Listing 17-9 . Sample Code to Set Package Properties Using a Script Task
public void Main()
{
// TODO: This would be set from an external
configuration file
const string SourceSystemConnectionString = "...";
Dts.TaskResult = (int)ScriptResults.Success;
if (Dts.Connections.Contains("SourceSystem"))
{
ConnectionManager cm
= Dts.Connections["SourceSystem"];
cm.ConnectionString
= SourceSystemConnectionString;
}
else
{
// The expected connection manager wasn't found
- log and set an error status
Dts.Events.FireError(0, "Script Task",
"Could not find the
SourceSystem connection manager",
string.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
 
 
Search WWH ::




Custom Search