If Then Else based off DTSTaskExecResult

  • I have a package that uses an ActiveX Script Task to check for a file, my code looks like this:

    dim fso

    fso = createobject("Scriptiong.FileSystemObject")

    if fso.fileexists("MyFilePathAndNameHere") then

    main = DTSTaskExecResult_Success

    else

    main = DTSTaskExecResult_Failure

    end if

    What i want the package to do on this step is follow the success workflow line if the file is there and follow the failure workflow line if it is not. My problem is when i run the step manually by right clicking (Execute Step) i get the correct response a PASS if it is there a FAIL i fit is not. When i try to run the package on its own it fails and then stops, it wont follow the fialure line. Any ideas?

  • This should keep the DTS running on success.

    Main = DTSStepScriptResult_ExecuteTask

    As for keeping the DTS running on failure, this I have not been able to accomplish. It just stops dead generating an ugly error.

    Main=DTSStepScriptResult_DontExecuteTask

    Main=DTSTaskExecResult_Failure

    Both work to stop the Package but neither execute the failure task.

    thx

    A nod is as good as a wink to a blind bat.

  • I sometimes have to follow one set of steps on one condition and another set of steps on another condition. This is what I used.

    ' disable the step I don't want to run

    DTSGlobalVariables.Parent.Steps("Step I dont want").DisableStep = True

    ' set the step I want to run to the waiting status

    DTSGlobalVariables.Parent.Steps("Step i want").ExecutionStatus = DTSStepExecStat_Waiting

    A couple things you should know about this

    1) when you disable a step, it stays disabled until you close the package without saving, so I recommend that you enable it at the point where it could possibly run again

    2) the steps that run after your next step have to be joined by a workflow (arror on success or failure) or they won't run

    3) the name of the step goes in the quotes. You get the name from the workflow properties. It is usually something like "DTSStep_DTSActiveScriptTask_4"

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

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