Learn how to a build a cloud-first strategyRegister Now


DTSStepScriptResult_DontExecuteTask  return status issue

Posted on 2006-03-24
Medium Priority
Last Modified: 2007-12-19

I'm processing a number of files from a folder.If the first file has a size 0, I want to stop the task but wish to process the other files. I'm using the following code in the Workflow properties.
Function Main()

        Dim oFSO, sFileName1,oFile

        ' Get filename from the Connections
        sFilename1 = DTSGlobalVariables.Parent.Connections("InputFile").DataSource

        Set oFSO = CreateObject("Scripting.FileSystemObject")

    Set oFile = oFSO.GetFile(sFilename1)

    If oFile.Size > 0 Then

                Main = DTSStepScriptResult_ExecuteTask
                Main = DTSStepScriptResult_DontExecuteTask
        End If

    Set oFile = Nothing
    Set oFSO = Nothing

End Function
It detects the  first file size is 0 and therefore does
not run the task which is fine but 'DTSStepScriptResult_DontExecuteTask' seems to be returning a 'failure' status and therefore the rest of the files from the folder are not being picked up.

Is there any workaround or a way to force DTSStepScriptResult_DontExecuteTask to return a 'success' status which will enable the other files to be processed?

Question by:Perjey

Expert Comment

ID: 16280227
create a dts package that loops thru all of the files only.
have it delete all of the 0 length files from then directory.
then run your processing package.
LVL 75

Accepted Solution

Anthony Perkins earned 2000 total points
ID: 16280609
Assuming you are using something like this article:
Looping, Importing and Archiving

Than all you have to do is make the following change in the ShouldLoop function:

Function ShouldILoop

Dim fso
Dim fil      
Dim fold
Dim pkg
Dim counter

set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")

set fold = fso.GetFolder(DTSGlobalVariables("gv_FileLocation").Value)

counter = fold.files.count

' So long as there are text files in the directory carry on

if  counter >= 1  then
      for each fil in fold.Files
            If fil.Size > 0 Then            ' Add this
                  DTSGlobalVariables("gv_FileFullName").Value = fil.path
                  ShouldILoop = CBool(True)
                  Exit For            ' No need to go any further
            End If
            ' ShouldILoop = CBool(True)     ' Comment this out
      ShouldILoop = CBool(False)
End if

End Function

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question