I have a package that uses a flat file source with a footer row that contains the number of rows in the file. I have a row count component count the rows and store the number in a variable. Then, I put a script component next and retrieved the value in the footer to see if it matched the row count variable. Everything works as planned, except I want to "fail" the whole package if the numbers don't match. Right now, I have a message box that tells whether they match or not. But whether they do or don't, the package still runs to completion. How do I set it to fail. I tried "Dts.TaskResult = Dts.Results.Failure", but that Dts statement is highlighted with dts is not declared and if I use intellisense to type it in, it is not available even though I have: Imports Microsoft.SqlServer.Dts.Pipeline.WrapperImports Microsoft.SqlServer.Dts.Runtime.Wrapper' Microsoft SQL Server Integration Services Script Component' Write scripts using Microsoft Visual Basic 2008.' ScriptMain is the entry point class of the script.Imports SystemImports System.DataImports System.MathImports Microsoft.SqlServer.Dts.Pipeline.WrapperImports Microsoft.SqlServer.Dts.Runtime.Wrapper<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _<CLSCompliant(False)> _Public Class ScriptMain Inherits UserComponent Dim intRowCount As Integer Dim intRowCountFromFile As Integer Dim blnFailPackage As Boolean Dim i As Integer Public Overrides Sub PreExecute() MyBase.PreExecute() intRowCount = 0 intRowCountFromFile = 0 blnFailPackage = False i = 0 End Sub Public Overrides Sub PostExecute() MyBase.PostExecute() 'Me.intRowCountFromFile = intRowCountFromFile - 1 Try If Me.Variables.intTotalRows - 2 = intRowCountFromFile Then MsgBox("Row counts matched - " & intRowCountFromFile & " data rows.") Else MsgBox("Row counts NOT matched - " & intRowCountFromFile & " data rows from file vs: " & Me.Variables.intTotalRows - 1 & " data rows actually counted.") blnFailPackage = True Throw New Exception("Rows Do Not Match") End If Catch e As Exception Console.WriteLine("Message: " & e.Message) MsgBox("Message: " & e.Message) While Not e.InnerException Is Nothing e = e.InnerException MsgBox(e.InnerException) 'Me.ComponentMetaData.FireError(-1, "", "InnerException: " + e.Message, "", True) End While Finally Console.WriteLine( _ "Finally executed in Throw Exception With Catch") Dts.TaskResult = Dts.Results.Failure End Try Console.WriteLine("End") End Sub Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) If Mid(Row.Col0, 1, 2) = "TR" Then intRowCountFromFile = Int(Trim(Mid(Row.Col0, 4, 13))) End If End SubEnd Class
Though the package runs, the Catch block does not execute at all and I don't know what to do with it when it does not match in order to fail it or stop the package. Any help would be appreciated. I've been struggling with this too long already and there is little usable documentation.Duane