Created
June 9, 2016 20:15
-
-
Save matt40k/191f8e28c3bc68df5d6340d9a30f9859 to your computer and use it in GitHub Desktop.
SSIS - Fires the connection strings into information messages - from http://sqlblog.com/blogs/jamie_thomson/archive/2011/10/25/verify-a-connection-before-using-it-ssis.aspx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Main() | |
{ | |
bool failure = false; | |
bool fireAgain = true; | |
foreach (var ConnMgr in Dts.Connections) | |
{ | |
Dts.Events.FireInformation(1, "", String.Format("ConnectionManager='{0}', ConnectionString='{1}'", | |
ConnMgr.Name, ConnMgr.ConnectionString), "", 0, ref fireAgain); | |
try | |
{ | |
ConnMgr.AcquireConnection(null); | |
Dts.Events.FireInformation(1, "", String.Format("Connection acquired successfully on '{0}'", | |
ConnMgr.Name), "", 0, ref fireAgain); | |
} | |
catch (Exception ex) | |
{ | |
Dts.Events.FireError(-1, "", String.Format("Failed to acquire connection to '{0}'. Error Message='{1}'", | |
ConnMgr.Name, ex.Message), | |
"", 0); | |
failure = true; | |
} | |
} | |
if (failure) | |
Dts.TaskResult = (int)ScriptResults.Failure; | |
else | |
Dts.TaskResult = (int)ScriptResults.Success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment