What is wrong with me?!? Or rather what is wrong with everyone else on the internet? Why won’t anyone post a little article on how to create a message box in an SSIS package so I can easily google it? Must I do everything around here?
Confession: I don’t know jack about C#. Creating a message box is probably one of the most basic tasks ever but having never written any C# I can never remember how to do this and I can never find a blog post on how to do it. Essentially, when it comes to creating a message box to check the state of a variable in SQL Server Integration Services I’m like the guy in Momento. (Bam! Momento. Best amnesia movie ever? Probably. Hmm, perhaps I should take a Polaroid of the code to help me remember…)
- Add a Script Task to your Control Flow. Note: “Script Task” not “ActiveX Script Task”.
- Open the task and click the “Edit Script” button near the bottom of the window.
- Scroll to the bottom of the default code and replace
public void Main() { // TODO: Add your code here Dts.TaskResult = (int)ScriptResults.Success; }
with
public void Main() { MessageBox.Show(Dts.Variables["User::YourVariableNameHere"].Value.ToString()); }
- Save and close the ssisscript window.
- Then, add your variable to the ReadOnlyVariables section.
- Click OK
That should do the trick. Hopefully, writing this post will do the trick for me and help me remember how to do this (and I won’t have to resort to Polaroids and tattoos.)
One response to “Create a MessageBox in SSIS with C#”
This is fantastic. Thank you very much.