Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SSIS: Stop Package in Script Task

Posted on 2013-11-29
2
Medium Priority
?
2,356 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
[X]
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
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 750 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
I have a large data set and a SSIS package. How can I load this file in multi threading?
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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