Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SSIS: Stop Package in Script Task

Posted on 2013-11-29
2
2,089 Views
Last Modified: 2016-02-11
Hi All,

I want to stop a package (I think the only way to do it is via script task) when the current package generates an error.

Anyway, I'm not familiar with VB that much and I found this method of stopping a package. I've tried to use it below
	Public Sub Main()
		'
		' Add your code here
        '
        Dim pkg As RunningPackage
        pkg.Stop()

		Dts.TaskResult = ScriptResults.Success
	End Sub

End Class

Open in new window


but I get an error message
Variable 'pkg' is used before it has been assigned a value. A null reference exception could result at runtime
.

Can anyone help me to write the correct syntax.

Thanks,

OS

-PS I'm using this within the On Error event handler.
0
Comment
Question by:onesegun
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
ID: 39685670
>stop a package ... when the current package generates an error.
That should already be happening.  If the package throws a runtime error, it will execute anything found in that control/container/package's OnError property and exit.

Define what you mean be 'error'.
0
 

Author Comment

by:onesegun
ID: 39689916
Ah ok.

I'm using a Foreach Loop Container and a script task which counts the number of loops when the Foreach Loop container finds a file meeting the specific requirement.

http://microsoft-ssis.blogspot.co.uk/2012/06/stop-package-when-foreach-loop-does-not.html

But I guess what you are saying is that once the package fails by purposely returning a failure then there is no need to actually stop the package?

By the way do you know how I would write the syntax anyway if I actually wanted to stop a package executing based on some condition (i.e. not package failure).

Thanks....
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Lessons learned during ten years of interviewing for SQL Server Integration Services (SSIS) and other Extract-Transform-Load (ETL) contract roles and two years of staff manager interviewing contractors.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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