How to run a step using ActiveX script

  • Hi All,

    [font="Courier New"](SQL Server 2000 SP4 on Windows 2003)[/font]

    I have a DTS package that loads data from a text file to a table. The first validation is to check if the correct file is in the relevant folder so that the same file is not loaded multiple times. If the file does not exist I stop the DTS using an ActiveX script within the workflow of the Bulk Load task.

    What I would now like to do is to instead of stopping the DTS completely to run another step in the same package (without using On Failure). So I need to know how to call/execute a step in the above ActiveX script. So the logic would be something like:

    [check file exists] ----> NO ---->

    [execute ActiveX script within Bulk Load workflow to stop execute of step] -----> [use same ActiveX script to execute another step].

    I have absolutely no ActiveX/VB Script experience. All the code I have used has been cobbled together from various websites. As I understand I need to use the DTS Object Model (here) but I just don't know how to do that!

    The script I've written does not work:

    Option Explicit

    Function Main()

    Dim oFSO, sFileName, oPkg, oActiveX

    ' Get the name of the file from the global variable "NextITOLFileName"

    sFilename = DTSGlobalVariables("NextITOLFileName").Value

    Set oFSO = CreateObject("Scripting.FileSystemObject")

    Set oPkg = DTSGlobalVariables.Parent

    Set oActiveX = oPkg.Task.ActiveScriptTask("DTSTask_DTSActiveScriptTask_1")

    ' Check for file and return appropriate result

    If oFSO.FileExists(sFilename) Then

    ' run the bulk load task

    Main = DTSStepScriptResult_ExecuteTask

    Else

    ' file missing, so run a different task

    ' THIS IS THE BIT THAT DOES NOT WORK

    oActiveX.Execute

    End If

    Set oFSO = Nothing

    Set oActiveX = Nothing

    Set oPkg = Nothing

    End Function

    Please help!

  • In case anyone is interested, this question was answered here:

    http://social.technet.microsoft.com/Forums/en-US/sqlintegrationservices/thread/9592e405-75b6-4012-b91d-5af1790ce6d6

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply