Q:

Forcing a For Loop Task to fail

I'm very new to SSIS, so maybe this is trivial, but so far I haven't been able to find anything helpful through google or previous questions. 
First, I have a package that takes an excel sheet that comes from an SSRS subscription and sends it off to the interested parties. The problem is that sometimes data isn't available yet and so the spreadsheet is completely empty save for named columns. I'm trying to include logic in the package, in a For Loop, that will check if the report is empty. if it is, notify those parties that there will be a delay and that the package will run 2 more times at 30 minute intervals. If the report is still empty after the 3rd attempt, then it will send an email that there's no data available and it will try again tomorrow.
My problem is that I can't figure out how to force the for loop task to fail if its loop count reaches a number.

A:

Something like this should work ... Add a script component to the control flow and include your loop counter in the ReadOnly variable list, The below script will succeed where LoopCount = 0, but will fail once LoopCount = 1.

    Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
    If CInt(Dts.Variables("LoopCount").Value.ToString) = 0 Then
        Dts.TaskResult = Dts.Results.Success
    Else
        Dts.TaskResult = Dts.Results.Failure
    End If
End Sub
End Class

