How do you terminate a DTS without indicating failure?

Last Post 28 Mar 2006 10:20 PM by simon.littlehales. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
simon.littlehales
New Member
New Member

--
22 Mar 2006 04:47 AM
I have an ActiveX step that searches for a file to import every 10 minutes.

If the file is there, i return DTSTaskExecResult_Success and the DTS moves to the import routine.
If the file is not there, i return DTSStepScriptResult_DontExecuteTask
Unfortunatley, this seems to indicate the DTS failed with an error. I want it to fail silently and indicate a success.

Here's the code:

Function Main()
Dim fso 'File system object
Set fso = CreateObject("Scripting.FileSystemObject")
IF (fso.FileExists(DTSGlobalVariables("FilePath").Value)) THEN
Set f = fso.GetFile(DTSGlobalVariables("FilePath").Value)
'Record Date & Time file created:
DTSGlobalVariables("dtFileDateTime").Value = f.DateCreated
Main = DTSTaskExecResult_Success
ELSE
Main = DTSStepScriptResult_DontExecuteTask
END IF
End Function

This DTS is called from a stored proc using dtsRun.
If the file is not there, i don't want dtsRun to return 1 indicating an error.
The above code always returns 1 if the file isn't there!
How can I terminate the DTS without indicating a failure?
simon.littlehales
New Member
New Member

--
28 Mar 2006 10:20 PM
Thanks dcapelo, yes, that will indicate success but then the DTS will carry on to the next step. I wanted it to stop running. I've actually solved this now by disabling the next step in code:

Function Main()
'Get the DTS object...
Dim pkg
SET pkg = DTSGlobalVariables.Parent

Dim fso 'File system object
Set fso = CreateObject("Scripting.FileSystemObject")
IF (fso.FileExists(DTSGlobalVariables("FilePath").Value)) THEN
'File found, do stuff to it here...

'Ensure next step is enabled:
pkg.Steps("DTSStep_DTSActiveScriptTask_2").DisableStep=False
ELSE
'File not found, exit silently by disabling next step:
pkg.Steps("DTSStep_DTSActiveScriptTask_2").DisableStep=True
END IF
'Indicate success wether file found or not
Main = DTSTaskExecResult_Success
End Function
simon.littlehales
New Member
New Member

--
28 Mar 2006 10:20 PM
Thanks dcapelo, yes, that will indicate success but then the DTS will carry on to the next step. I wanted it to stop running. I've actually solved this now by disabling the next step in code:

Function Main()
'Get the DTS object...
Dim pkg
SET pkg = DTSGlobalVariables.Parent

Dim fso 'File system object
Set fso = CreateObject("Scripting.FileSystemObject")
IF (fso.FileExists(DTSGlobalVariables("FilePath").Value)) THEN
'File found, do stuff to it...
pkg.Steps("DTSStep_DTSActiveScriptTask_2").DisableStep=False
ELSE

pkg.Steps("DTSStep_DTSActiveScriptTask_2").DisableStep=True
END IF
Main = DTSTaskExecResult_Success
End Function
You are not authorized to post a reply.

Acceptable Use Policy