{"id":373,"date":"2012-11-16T12:55:44","date_gmt":"2012-11-16T19:55:44","guid":{"rendered":"http:\/\/www.sqldbpros.com\/?p=373"},"modified":"2015-04-14T13:53:35","modified_gmt":"2015-04-14T20:53:35","slug":"create-a-messagebox-in-ssis-with-c","status":"publish","type":"post","link":"http:\/\/sqldbpros.com\/wordpress\/2012\/11\/create-a-messagebox-in-ssis-with-c\/","title":{"rendered":"Create a MessageBox in SSIS with C#"},"content":{"rendered":"<p>What is wrong with me?!?\u00a0 Or rather what is wrong with everyone else on the internet?\u00a0 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?\u00a0 Must I do everything around here?<\/p>\n<p>Confession: I don't know jack about C#.\u00a0 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.\u00a0 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.\u00a0 (Bam! <a href=\"http:\/\/www.amazon.com\/gp\/product\/B004FHCH96\/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B004FHCH96&amp;linkCode=as2&amp;tag=grocwine-20\" target=\"_blank\">Momento<\/a>.\u00a0 Best amnesia movie ever?\u00a0 Probably.\u00a0 Hmm, perhaps I should take a Polaroid of the code to help me remember...)<!--more--><\/p>\n<p><figure id=\"attachment_395\" aria-describedby=\"caption-attachment-395\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBox1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-395\" title=\"SSISMessageBox\" src=\"http:\/\/www.sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBox1.jpg\" alt=\"\" width=\"550\" height=\"309\" srcset=\"http:\/\/sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBox1.jpg 550w, http:\/\/sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBox1-300x168.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-395\" class=\"wp-caption-text\">Why do I have \"MessageBox.Show(Dts.Variables[\"YourVariableHere\"].Value.ToString())\" tattooed on my arm?<\/figcaption><\/figure>So without further ado.<\/p>\n<ol>\n<li>Add a Script Task to your Control Flow. Note: \"Script Task\" not \"ActiveX Script Task\".<\/li>\n<li>Open the task and click the \"Edit Script\" button near the bottom of the window.<\/li>\n<li>Scroll to the bottom of the default code and replace\n<pre>        public void Main()\r\n        {\r\n            \/\/ TODO: Add your code here\r\n            Dts.TaskResult = (int)ScriptResults.Success;\r\n        }<\/pre>\n<p>with<\/p>\n<pre> public void Main()\r\n        {\r\n            MessageBox.Show(Dts.Variables[\"User::YourVariableNameHere\"].Value.ToString());\r\n\r\n        }<\/pre>\n<\/li>\n<li>Save and close the <em>ssisscript<\/em> window.<\/li>\n<li>Then, add your variable to the ReadOnlyVariables section.<br \/>\n<a href=\"http:\/\/www.sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBoxVariable.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-375\" title=\"SSISMessageBoxVariable\" src=\"http:\/\/www.sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBoxVariable.png\" alt=\"\" width=\"601\" height=\"510\" srcset=\"http:\/\/sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBoxVariable.png 601w, http:\/\/sqldbpros.com\/wordpress\/wp-content\/uploads\/2012\/11\/SSISMessageBoxVariable-300x254.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/a><\/li>\n<li>Click OK<\/li>\n<\/ol>\n<p>That should do the trick.\u00a0 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.)<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is wrong with me?!?\u00a0 Or rather what is wrong with everyone else on the internet?\u00a0 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?\u00a0 Must I do everything around here? Confession: I don't know jack about C#.\u00a0 Creating a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,47,43,46],"tags":[20,92,91,93,10,94,9,11,49],"class_list":["post-373","post","type-post","status-publish","format-standard","hentry","category-businss-intelligence","category-etl","category-microsoft-sql-server","category-sql-server-integration-services-ssis","tag-business-intelligence","tag-c","tag-memento","tag-message-box","tag-ms-sql","tag-msgbox","tag-sql-server","tag-sql-server-2008","tag-sql-server-integration-services"],"_links":{"self":[{"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/posts\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/comments?post=373"}],"version-history":[{"count":20,"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/posts\/373\/revisions"}],"predecessor-version":[{"id":813,"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/posts\/373\/revisions\/813"}],"wp:attachment":[{"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/media?parent=373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/categories?post=373"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sqldbpros.com\/wordpress\/wp-json\/wp\/v2\/tags?post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}