Create a MessageBox in SSIS with C#

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…)

Why do I have “MessageBox.Show(Dts.Variables[“YourVariableHere”].Value.ToString())” tattooed on my arm?
So without further ado.

  1. Add a Script Task to your Control Flow. Note: “Script Task” not “ActiveX Script Task”.
  2. Open the task and click the “Edit Script” button near the bottom of the window.
  3. Scroll to the bottom of the default code and replace
            public void Main()
                // TODO: Add your code here
                Dts.TaskResult = (int)ScriptResults.Success;


     public void Main()
  4. Save and close the ssisscript window.
  5. Then, add your variable to the ReadOnlyVariables section.
  6. 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#”

Leave a Reply

Your email address will not be published.