Solved

SSIS: Stop Package in Script Task

Posted on 2013-11-29
2
1,994 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Over the last 2 years, I have been working on SSIS 2008. Really the tough tasks in SSIS are to deploy packages and pass parameters (Values from outside package). The latter is certainly a headache for developers, particularly for me. We had to ma…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now