ActiveScriptTask Object
The ActiveScriptTask object defines a task that is a Microsoft® ActiveX® script. ActiveX Script tasks do not use the data pump and therefore do not have access to the Connections collection or Data Transformation Services (DTS) source and destination collections. However, ActiveScriptTask objects have full access to the GlobalVariables collection, which provides a way to share information across tasks.
Script languages available on a particular system can be determined by enumerating the ScriptingLanguageInfos collection of the Application object. For more information about the scripting language appropriate for use with DTS, see ScriptingLanguageInfo Object.
Example
The following Microsoft Visual Basic® code creates ActiveScriptTask and Step objects. The ActiveX script returns DTSTaskExecResult_Success or DTSTaskExecResult_Failure, depending on the value of a global variable. The success or failure return can be used to direct the workflow of subsequent steps in the package.
Dim objPackage As DTS.Package2
Dim objStep As DTS.Step
Dim objTask As DTS.Task
Dim objScripTask As DTS.ActiveScriptTask
. . .
'create step and task, specify script, func name and language
Set objStep = objPackage.Steps.New
Set objTask = objPackage.Tasks.New("DTSActiveScriptTask")
Set objScripTask = objTask.CustomTask
With objScripTask
.Name = "AXScr_Task"
.ActiveXScript = _
"Function Main()" & vbCrLf & _
"If DTSGlobalVariables( ""GlobalOne"" ) > 0 Then" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Success" & vbCrLf & _
"Else" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Failure" & vbCrLf & _
"End If" & vbCrLf & _
"End Function"
.FunctionName = "Main"
.ScriptLanguage = "VBScript"
End With
'link step to task to package
objStep.TaskName = objScripTask.Name
objStep.Name = "AXScr_Step"
With objPackage
.Steps.Add objStep
.Tasks.Add objTask
.FailOnError = False
End With
Note If an ActiveX script returns DTSTaskExecResult_Failure and the FailOnError property of the Package2 object is TRUE, the entire package will fail.
See Also
Application Object
ScriptingLanguageInfos Collection