<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Microsoft At Productive Edge</title>
	<atom:link href="http://microsoft.productiveedge.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://microsoft.productiveedge.com</link>
	<description>A little Microsoft corner at Productive Edge</description>
	<lastBuildDate>Sat, 05 Jan 2013 20:58:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Umbraco 5 Data Migration / Restore Issue</title>
		<link>http://microsoft.productiveedge.com/umbraco-5-data-migration-restore-issue/</link>
		<comments>http://microsoft.productiveedge.com/umbraco-5-data-migration-restore-issue/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 19:41:49 +0000</pubDate>
		<dc:creator>Carson.Junginger</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[Data Migration]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Fix]]></category>
		<category><![CDATA[Install]]></category>
		<category><![CDATA[Umbraco 5]]></category>
		<category><![CDATA[Umbraco Jupiter]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=191</guid>
		<description><![CDATA[I recently migrated an Umbraco 5 site from a live environment to my local environment to make some changes, and ran into an issue. I backed up the database of the live site and restored it locally, updated the connection string located in the Hive config file to point to my local database (located at [...]]]></description>
			<content:encoded><![CDATA[<p>I recently migrated an Umbraco 5 site from a live environment to my local environment to make some changes, and ran into an issue.  I backed up the database of the live site and restored it locally, updated the connection string located in the Hive config file to point to my local database (located at ~\App_Data\Umbraco\HiveConfig\web.config), and the site still would not load.  I was presented with the following screen:</p>
<div style="font-family:Courier, Courier New, Serif;">
Umbraco 5<br />
Install Umbraco 5.0.0 RTM<br />
Welcome to Umbraco 5<br />
It looks like Umbraco isn&#8217;t installed yet &#8211; click here to launch the install wizard.<br />
Umbraco 5.0.0 RTM runs on ASP.NET MVC3. This is a standard MVC-powered page included as a demo of how your MVC application can serve pages alongside those managed by Umbraco CMS.<br />
To learn more about ASP.NET MVC visit http://asp.net/mvc
</div>
<p><br/></p>
<p>After a few minutes of troubleshooting, I discovered that the issue was simply that the production environment was using a different user account for Umbraco to access the database than I was using locally, and even though I changed the connection string to reflect this, I forgot to associate the username with the database after the restore:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2012/03/2.jpg"><img src="http://microsoft.productiveedge.com/wp-content/uploads/2012/03/2.jpg" alt="Umbraco SQL Server Login Properties" title="SQL Server Login Properties" width="560" class="aligncenter size-full wp-image-193" /></a></p>
<p>After checking the appropriate database roles for my user account everything was working again.  Since Umbraco 5 doesn&#8217;t error or give any warning about why it is at the install screen, this wasted a little bit of my time.  Hopefully this helps one of you troubleshoot a similar issue.</p>
<p>-Carson</p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/umbraco-5-data-migration-restore-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error &#8211; Exception has been thrown by the target of an invocation.</title>
		<link>http://microsoft.productiveedge.com/error-exception-has-been-thrown-by-the-target-of-an-invocation/</link>
		<comments>http://microsoft.productiveedge.com/error-exception-has-been-thrown-by-the-target-of-an-invocation/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 17:09:48 +0000</pubDate>
		<dc:creator>Carson.Junginger</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Web Site]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=184</guid>
		<description><![CDATA[I have recently been working with Umbraco 5 (Jupiter), the newest version rebuilt from the ground up using ASP.NET MVC. One of the stranger issues that I ran into occurred after adding a Surface Controller, and a corresponding custom View to the pre-compiled site. The following error showed up after a build/save all: The pre-application [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been working with Umbraco 5 (Jupiter), the newest version rebuilt from the ground up using ASP.NET MVC.  One of the stranger issues that I ran into occurred after adding a Surface Controller, and a corresponding custom View to the pre-compiled site.  The following error showed up after a build/save all:</p>
<p><code><br />
The pre-application start initialization method Start on type System.Web.WebPages.Deployment.<wbr>PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation.<br />
</code></p>
<p>Since I opened the site up as an ASP.NET MVC3 <strong>Web Site</strong>, adding the view added the following to the Web.config:</p>
<p><code>&lt;add key="webpages:Enabled" value="true" /></code></p>
<p>Since it does this behind the scenes, I was confused about how the error started, and wasn&#8217;t able to catch it until doing a compare on a fresh Umbraco web.config, and the one that was in the project root. Hopefully this saves some of you some time</p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/error-exception-has-been-thrown-by-the-target-of-an-invocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC CheckBoxFor explained</title>
		<link>http://microsoft.productiveedge.com/asp-net-mvc-checkboxfor-explained/</link>
		<comments>http://microsoft.productiveedge.com/asp-net-mvc-checkboxfor-explained/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 15:35:59 +0000</pubDate>
		<dc:creator>Carson.Junginger</dc:creator>
				<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=172</guid>
		<description><![CDATA[I have had a number of people ask about the CheckBoxFor method, and why it renders a hidden input tag with a value of false alongside the checkbox input. Here&#8217;s an example: @Html.CheckBoxFor(m => m.IsEnabled) will render &#60;input id="IsEnabled" type="checkbox" value="true" name="IsEnabled"> &#60;input type="hidden" value="false" name="IsEnabled"> The reason this is done is because a form [...]]]></description>
			<content:encoded><![CDATA[<p>I have had a number of people ask about the CheckBoxFor method, and why it renders a hidden input tag with a value of false alongside the checkbox input.  Here&#8217;s an example:</p>
<p><code style="font-size:14px;">@Html.CheckBoxFor(m => m.IsEnabled)</code></p>
<p>will render<br />
<code style="font-size:14px;"><br />
&lt;input id="IsEnabled" type="checkbox" value="true" name="IsEnabled"><br />
&lt;input type="hidden" value="false" name="IsEnabled"><br />
</code></p>
<p>The reason this is done is because a form will not post anything to the server for an unchecked checkbox.  In ASP.NET MVC, most of the time you are going to want a &#8220;false&#8221; value to be posted to the model binder, so the hidden value of false is there so that a value is posted back whether the checkbox is checked or not.  If the checkbox is not checked, the form value for &#8220;IsEnabled&#8221; will be &#8220;false&#8221;, and if it is checked, both values will be posted as &#8220;true,false&#8221;.  The model binder understands this, and will automatically take the true value from the collection of values.  I have read that Ruby on Rails and MonoRail also use a similar technique. </p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/asp-net-mvc-checkboxfor-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ to SQL Connection String</title>
		<link>http://microsoft.productiveedge.com/linq-to-sql-connection-string/</link>
		<comments>http://microsoft.productiveedge.com/linq-to-sql-connection-string/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 21:37:08 +0000</pubDate>
		<dc:creator>Carson.Junginger</dc:creator>
				<category><![CDATA[.NET 2.0]]></category>
		<category><![CDATA[.NET 3.0]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=142</guid>
		<description><![CDATA[Sometimes when working with LINQ to SQL the designer can act screwy and generate a bunch of connection strings in the Web.config, or build the connection string used to access the server into the binary.  I am going to show a method I use to ensure that LINQ2SQL uses the correct connection string by creating [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes when working with LINQ to SQL the designer can act screwy and generate a bunch of connection strings in the Web.config, or build the connection string used to access the server into the binary.  I am going to show a method I use to ensure that LINQ2SQL uses the correct connection string by creating a partial class with the same name as the generated data context.</p>
<p>First, create a new partial class in the same namespace as your LINQ2SQL DBML file.  Name the class the same name as the file with &#8220;DataContext&#8221; at the end. For example, if my LINQ2SQL file is &#8220;Example.dbml&#8221; my class name will be &#8220;ExampleDataContext.&#8221;</p>
<p>Next, add a default constructor like the one shown, replacing the constructor name and connection string key to your own values:</p>
<pre class="syntax csharp">

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.Linq;

namespace Example
{
    partial class ExampleDataContext
    {
        public ExampleDataContext()
            : base(ConfigurationManager.ConnectionStrings[&quot;ExampleConnectionString&quot;].ConnectionString, mappingSource)
        {

        }
    }
}
</pre>
<p>Now, whenever you edit your DBML file, make sure to set the &#8220;ApplicationSettings&#8221; property to false, and delete the connection string that was auto-generated.</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2011/08/4.png"><img class="size-full wp-image-159 alignnone" title="DBML Properties" src="http://microsoft.productiveedge.com/wp-content/uploads/2011/08/4.png" alt="" width="396" height="281" /></a></p>
<p>Now your data layer will always use the correct connection string (when you use the default constructor), and the DBML designer will stop tossing in extra connection strings.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/linq-to-sql-connection-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Domain Users to a Server 2008 R2 Domain</title>
		<link>http://microsoft.productiveedge.com/adding-domain-users-to-a-server-2008-r2-domain/</link>
		<comments>http://microsoft.productiveedge.com/adding-domain-users-to-a-server-2008-r2-domain/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 18:00:34 +0000</pubDate>
		<dc:creator>Larry.Smithmier</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Domain Controller]]></category>
		<category><![CDATA[dsadd]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Server 2008 R2]]></category>
		<category><![CDATA[Add User]]></category>
		<category><![CDATA[Example]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=114</guid>
		<description><![CDATA[The command line you would use to add a new user is: dsadd user "CN=First Last,CN=User,DC=corp,DC=productiveedge,DC=com" -samid first.last -pwd qwerty123! -mustchpwd yes
so you can create a script to add users to a domain relatively easily.  Note the: -mustchpwd yes
at the end of the line.  That is added to require the user to change their password on the first login.]]></description>
			<content:encoded><![CDATA[<p>I have a long list of users to add to an existing domain, and using the Active Directory Users and Computers GUI:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image2.png"><img style="display: inline; border: 0px;" title="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb2.png" border="0" alt="image" width="453" height="353" /></a></p>
<p>is an easy way to add a couple of users:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image3.png"><img style="display: inline; border: 0px;" title="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb3.png" border="0" alt="image" width="273" height="77" /></a></p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image4.png"><img style="display: inline; border: 0px;" title="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb4.png" border="0" alt="image" width="458" height="390" /></a></p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image5.png"><img style="display: inline; border: 0px;" title="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb5.png" border="0" alt="image" width="459" height="390" /></a></p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image6.png"><img style="display: inline; border: 0px;" title="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb6.png" border="0" alt="image" width="458" height="387" /></a></p>
<p>but with over 40 to add, it would take too long.  How can I speed this up?  dsadd to the rescue!  The command line you would use to add a new user is:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:f256bf42-f74f-4c1c-9eec-633fd1382b22" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush:text">
dsadd user "CN=First Last,CN=User,DC=corp,DC=productiveedge,DC=com" -samid first.last -pwd qwerty123! -mustchpwd yes
</pre>
</div>
<p>so you can create a script to add users to a domain relatively easily.  Note the:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:22c36833-7023-4e00-9b33-77fe68455cea" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush:text">
-mustchpwd yes
</pre>
</div>
<p>at the end of the line.  That is added to require the user to change their password on the first login.</p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/adding-domain-users-to-a-server-2008-r2-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Troubleshoot SQL Server Connection Issues</title>
		<link>http://microsoft.productiveedge.com/how-to-troubleshoot-sql-server-connection-issues/</link>
		<comments>http://microsoft.productiveedge.com/how-to-troubleshoot-sql-server-connection-issues/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 05:34:46 +0000</pubDate>
		<dc:creator>Larry.Smithmier</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[UDL]]></category>
		<category><![CDATA[Universal Data Link]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=98</guid>
		<description><![CDATA[The easiest way to test connection issues with Universal Data Link (.udl) files. No code required. Simply create an empty text file on a Windows machine with the extension .udl and double click it. ]]></description>
			<content:encoded><![CDATA[<p>The easiest way to test connection issues with <a href="http://msdn.microsoft.com/en-us/library/e38h511e%28VS.71%29.aspx">Universal Data Link (.udl) files</a>. No code required. Simply create an empty text file on a Windows machine with the extension .udl and double click it.</p>
<p><img src="http://i.imgur.com/nRLkP.png" alt="alt text" /></p>
<p>A wizard pops up and you can test your configuration pretty quickly.  If you did a default install of anything other than SQL Express, your instance name (the part to the right of the &#8216;\&#8217; below) will default to MSSQLSERVER and shouldn’t be shown in the server name.  If you installed SQLExpress, your instance name will be SQLEXPRESS.</p>
<p><img src="http://i.imgur.com/Ryi1w.png" alt="alt text" /></p>
<p>And, as a bonus, once you get it working you can open it in a text editor and extract your connection string. If it doesn&#8217;t work on your local box, try it on the server itself. If that works, skip on down to the end of this for the culprit.</p>
<p>You can also attempt to telnet directly to port 1433 (the default TCP/IP port for SQL Server) to test connectivity.  You won’t see anything once you get there, but if the connection succeeds, you are in business.</p>
<p>If you are not running SQL Server locally, you could also get into trouble if remote connections are not allowed. To check/change this, Open up Management Studio and right click on the instance you are connected to:</p>
<p><img src="http://i.imgur.com/v9iQo.png" alt="alt text" /></p>
<p>open the properties window:</p>
<p><img src="http://i.imgur.com/5eSsX.png" alt="alt text" /></p>
<p>and go to the connections tab and insure remote connections are allowed:</p>
<p><img src="http://i.imgur.com/ZnoId.png" alt="alt text" /></p>
<p>If none of that works, the problem you are probably having is related to the setup of SQL Server itself. Open up the SQL Server Configuration Manager:</p>
<p><img src="http://i.imgur.com/ECFbh.png" alt="alt text" /></p>
<p>then go to the SQL Server Network Configuration:</p>
<p><img src="http://i.imgur.com/KNPwj.png" alt="alt text" /></p>
<p>then double click on the Protocols for MSSQLSERVER:</p>
<p><img src="http://i.imgur.com/ird3R.png" alt="alt text" /></p>
<p>and make sure that TCP/IP is enabled:</p>
<p><img src="http://i.imgur.com/lIrkF.png" alt="alt text" /></p>
<p>If TCP/IP is enabled, you may be running into firewall issues (it requires port 1433 by default, but it can be configured to a different port).   To see which port your SQL instance is running on, double click on the TCP/IP icon to open the properties page and on the IP Address tab you will find the TCP port you are running on:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image1.png"><img style="display: inline; border: 0px;" title="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb1.png" border="0" alt="image" width="398" height="436" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/how-to-troubleshoot-sql-server-connection-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking up Stored Procedures Containing &#8216;%x%&#8217;</title>
		<link>http://microsoft.productiveedge.com/looking-up-stored-procedures-containing-x/</link>
		<comments>http://microsoft.productiveedge.com/looking-up-stored-procedures-containing-x/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 19:08:49 +0000</pubDate>
		<dc:creator>Larry.Smithmier</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Snippit]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Stored Procedures]]></category>
		<category><![CDATA[sys.procedures]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=94</guid>
		<description><![CDATA[This isn’t really big news, but I have had to look it up twice in the last quarter.&#160; To find which stored procedures contain a specific text string, use: SELECT Name, OBJECT_DEFINITION(OBJECT_ID) FROM sys.procedures sp WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Language%']]></description>
			<content:encoded><![CDATA[<p>This isn’t really big news, but I have had to look it up twice in the last quarter.&#160; To find which stored procedures contain a specific text string, use:</p>
<pre class="brush:sql">
SELECT Name, OBJECT_DEFINITION(OBJECT_ID)
FROM sys.procedures sp
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Language%'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/looking-up-stored-procedures-containing-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mystery Constants: Maintainability</title>
		<link>http://microsoft.productiveedge.com/mystery-constants-maintainability/</link>
		<comments>http://microsoft.productiveedge.com/mystery-constants-maintainability/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 19:32:30 +0000</pubDate>
		<dc:creator>Larry.Smithmier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[IntelliSense]]></category>
		<category><![CDATA[Legacy]]></category>
		<category><![CDATA[Maintainability]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[DotNet]]></category>
		<category><![CDATA[enumerations]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[IntellliSense]]></category>
		<category><![CDATA[Legacy code]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=91</guid>
		<description><![CDATA[Working with legacy code is always one of my favorite things to do.&#160; I believe it helps me write more maintainable code, and the little mysteries are always quite engaging.&#160; The most recent example that I feel compelled to share is related to the setting of a database value based on the selection made in [...]]]></description>
			<content:encoded><![CDATA[<p>Working with legacy code is always one of my favorite things to do.&#160; I believe it helps me write more maintainable code, and the little mysteries are always quite engaging.&#160; The most recent example that I feel compelled to share is related to the setting of a database value based on the selection made in a radio button group.&#160; In this particular instance, a set of custom localization routines help cloud the issue by abstracting the text from the code, but the central fault is more universal.&#160; There was an undocumented naming convention that was initially followed within the database, but the constraints on columns were not always put in place to enforce the convention and the code itself was not designed to assist in any way.</p>
<p>On to specifics (altered to insure confidentiality).&#160; </p>
<ul>
<li>Initially, in the UI there are three radio buttons that correspond to an integer column in the database (color).&#160; The value is set on a public property of an object that corresponds to the table (widgets) in the database.&#160; There is a corresponding dimension table (widgetColorCode) in the database, but there is a missing foreign key constraint and the naming convention doesn’t make it easy to track down the dimension domain. </li>
<li>Time passes. </li>
<li>A new UI is built for a new company that only manufactures red Widgets.&#160; The combo boxes are removed, and the value is set upon submission to the constant 1.&#160; </li>
<li>A derivative of the new UI is commissioned that is for a company only supplying blue Widgets.&#160;&#160; There is nothing in the code to help the programmer find what value this property should have.&#160; </li>
</ul>
<p>So the code for the Widget class looks something like this:</p>
<pre class="brush:csharp">    public class Widget
    {
        public int Color { get; set; }
    }</pre>
<p>I am a firm believer in having enumerations corresponding to all dimensions in a project.&#160; There is a performance hit for converting an enumeration to an integer, but it is far outweighed by the increased maintainability of the code.&#160; By explicitly setting the values for the enumeration and adding an XML comment relating it to the dimension table, you can greatly increase the maintainability of the code. When starting from scratch on a project, I will typically have something along the lines of:</p>
<pre class="brush:csharp">    ///
<summary>
    /// corresponds to the Widget fact table
    /// </summary>

    public class Widget
    {
        public WidgetColor Color { get; set; }
    }

    ///
<summary>
    /// corresponds to the WidgetColorCode dimension table
    /// </summary>

    public enum WidgetColor
    {
        Red = 1,
        White = 2,
        Blue = 3
    }</pre>
<p>But, that is a personal preference, and refactoring the entire code base at this point can’t be justified.&#160; What can be done quickly to lessen the impact of this when further maintenance is required?&#160; Visual Studio comes to the rescue!&#160; By simply adding an XML comment to the property, we can define the dimension so that hovering over the property will display the dimension information (Please excuse the missing pointer in the image, trust me, I am hovering over the Color property.):</p>
<pre class="brush:csharp">    ///
<summary>
    /// corresponds to the Widget fact table
    /// </summary>

    public class Widget
    {
        ///
<summary>
        /// corresponds to the WidgetColorCode dimension table
        /// 1: Red, 2: White, 3: Blue
        /// </summary>

        public int Color { get; set; }
    }</pre>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/10/image_thumb.png" width="542" height="151" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/mystery-constants-maintainability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending Email from SQL Server</title>
		<link>http://microsoft.productiveedge.com/sending-email-from-sql-server/</link>
		<comments>http://microsoft.productiveedge.com/sending-email-from-sql-server/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 08:22:05 +0000</pubDate>
		<dc:creator>Larry.Smithmier</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[DatabaseMail]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=81</guid>
		<description><![CDATA[I have a project that requires me to send contracts that are stored in SQL Server to customers and I started poking around for the best way to do it.&#160; First, I found a quick code snippet that sends an email using sp_send_dbmail: EXEC msdb.dbo.sp_send_dbmail @recipients = 'lsmithmier@productiveedge.com', @body = 'Just testing the mail', @subject [...]]]></description>
			<content:encoded><![CDATA[<p>I have a project that requires me to send contracts that are stored in SQL Server to customers and I started poking around for the best way to do it.&#160; First, I found a quick code snippet that sends an email using sp_send_dbmail:</p>
<pre class="brush:sql"> EXEC msdb.dbo.sp_send_dbmail
@recipients = 'lsmithmier@productiveedge.com',
@body = 'Just testing the mail',
@subject = 'Sending Mail using Database Mail' ;</pre>
<p>&#160;</p>
<p>When I first ran it on my database server (SQL Server 2008 R2) I got the following error:</p>
<pre>Msg 15281, Level 16, State 1, Procedure sp_send_dbmail, Line 0
SQL Server blocked access to procedure 'dbo.sp_send_dbmail' of component
'Database Mail XPs' because this component is turned off as part of the
security configuration for this server. A system administrator can enable the
use of 'Database Mail XPs' by using sp_configure. For more information about
enabling 'Database Mail XPs', see &quot;Surface Area Configuration&quot;
in SQL Server Books Online.</pre>
<p>So I cranked up Microsoft SQL Server Management Studio and set email up:</p>
<p>1.&#160; Open up the Management section and right click on the Database Mail item:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb2.png" width="288" height="297" /></a> </p>
<p>2.&#160; Choose <strong>Configure Database Mail</strong></p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb3.png" width="260" height="140" /></a></p>
<p>3.&#160; Click Next </p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb4.png" width="244" height="213" /></a> </p>
<p>4.&#160; Click Next</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb5.png" width="244" height="213" /></a> </p>
<p>5.&#160; Click Yes</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb6.png" width="244" height="53" /></a> </p>
<p>6.&#160; Set the <strong>Profile name</strong> and choose <strong>Add</strong> an SMTP account:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb7.png" width="244" height="214" /></a> </p>
<p>7.&#160; Enter your settings:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb8.png" width="244" height="211" /></a> </p>
<p>8.&#160; Set the profile as both <strong>Public</strong> and <strong>Default</strong>:</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb9.png" width="244" height="214" /></a> </p>
<p>9.&#160; Click Next</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb10.png" width="244" height="214" /></a> </p>
<p>10. Click Finish</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb11.png" width="244" height="213" /></a> </p>
<p>11. Click Close</p>
<p><a href="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://microsoft.productiveedge.com/wp-content/uploads/2010/09/image_thumb12.png" width="244" height="213" /></a> </p>
<p>and it is all setup!&#160; Really easy compared to the old way of setting email up with SQL Server.&#160; Then I re-ran the query and got the following response:</p>
<pre>Mail queued.</pre>
<p>&#160;</p>
<p>But then what?&#160; I ran a quick query and found that the email wasn’t sent correctly:</p>
<pre class="brush:sql"> use [msdb]
SELECT *
FROM sysmail_mailitems
GO
SELECT *
FROM sysmail_log
GO </pre>
<p>so I looked back over my settings and updated the port number to hit the outgoing relay and everything started working!</p>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/sending-email-from-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Telerik RadUpload User Control For Use in a RadGrid</title>
		<link>http://microsoft.productiveedge.com/creating-a-telerik-radupload-user-control-for-use-in-a-radgrid/</link>
		<comments>http://microsoft.productiveedge.com/creating-a-telerik-radupload-user-control-for-use-in-a-radgrid/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 22:56:00 +0000</pubDate>
		<dc:creator>Larry.Smithmier</dc:creator>
				<category><![CDATA[.NET 2.0]]></category>
		<category><![CDATA[.NET 3.0]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[RadGrid]]></category>
		<category><![CDATA[RadUpload]]></category>
		<category><![CDATA[Telerik]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[UserControl]]></category>

		<guid isPermaLink="false">http://microsoft.productiveedge.com/?p=52</guid>
		<description><![CDATA[I have been working with Telerik controls for a little over two months (the ASP.NET AJAX suite) and have been continuously impressed with the quality and power they provide.&#160; I am working on a project that requires the upload of several different file types which need to be displayed in a grid once uploaded.&#160; The [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working with Telerik controls for a little over two months (the ASP.NET AJAX suite) and have been continuously impressed with the quality and power they provide.&#160; I am working on a project that requires the upload of several different file types which need to be displayed in a grid once uploaded.&#160; The cleanest solution I could think of was to create a User Control to handle the uploads and embed it within the grid through the EditFormSettings FormTemplate.&#160; So first, I created a simple upload User Control as follows:</p>
<pre class="brush:csharp; html-script: true">
&lt;%@ Control Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;UploadControl.ascx.cs&quot;
    Inherits=&quot;WebApplication1.UserControls.UploadControl&quot; %&gt;
    <telerik:radupload id="RadUpload1" skin="Vista" maxfileinputscount="5" initialfileinputscount="2" controlobjectsvisibility="All" allowedfileextensions=".jpg,.jpeg,.gif,.png,.bmp,.tif,.tiff,.pdf" runat="server">
    </telerik:radupload>
    <telerik:radprogressmanager id="RadProgressManager1" runat="server" />
    <telerik:radprogressarea id="RadProgressArea1" skin="Vista" runat="server" progressindicators="TotalProgressBar, TotalProgress, RequestSize, FilesCountBar, FilesCount, SelectedFilesCount, CurrentFileName, TimeElapsed, TimeEstimated, TransferSpeed" displaycancelbutton="True">
    </telerik:radprogressarea>
    <asp:linkbutton id="btnSubmit" onclick="btnSubmit_Click" runat="server">Submit</asp:linkbutton></pre>
<p>with the code behind set up to store the uploaded files in the database using LINQ:</p>
<pre class="brush:csharp">
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            LinerModelDataContext dataContext = new LinerModelDataContext();
            foreach (UploadedFile file in RadUpload1.UploadedFiles)
            {
                byte[] bytes = new byte[file.ContentLength];
                file.InputStream.Read(bytes, 0, file.ContentLength);
                Attachment attachment = new Attachment();
                attachment.FileName = file.GetName();
                attachment.BinaryAttachment = bytes;
                attachment.CustomerID = this.CustomerID;
                dataContext.Attachments.InsertOnSubmit(attachment);
            }
            dataContext.SubmitChanges();
        }</pre>
<p>I then just added the EditFormSettings section to RadGrid1 and I was able to upload files:</p>
<pre class="brush:xml">
                    <EditFormSettings EditFormType="Template">
                        <EditColumn UniqueName="editColumn">
                        </EditColumn>
                        <FormTemplate>
                            <uc1:UploadControl ID="UploadControl1" runat="server" />
                        </FormTemplate>
                    </EditFormSettings></pre>
<p>But my grid wasn&#8217;t refreshing and I wasn&#8217;t getting any notification that the upload was complete.  So, to provide the user experience I wanted, I exposed an event to the grid from the upload control by modifying the code behind of the UserControl.  I added a delegate, and exposed the event as follows:</p>
<pre class="brush:csharp; highlight: [1, 6, 22, 23, 24, 25];">
    public delegate void UploadHandler();

    public partial class UploadControl : System.Web.UI.UserControl
    {
...
        public event UploadHandler Upload;

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            LinerModelDataContext dataContext = new LinerModelDataContext();
            foreach (UploadedFile file in RadUpload1.UploadedFiles)
            {
                byte[] bytes = new byte[file.ContentLength];
                file.InputStream.Read(bytes, 0, file.ContentLength);
                Attachment attachment = new Attachment();
                attachment.FileName = file.GetName();
                attachment.Attachment1 = bytes;
                attachment.CustomerID = this.CustomerID;
                dataContext.Attachments.InsertOnSubmit(attachment);
            }
            dataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
            if (Upload != null)
            {
                Upload.Invoke();
            }
        }</pre>
<p>and changing the FormTemplate to be:</p>
<pre class="brush:xml">
                        <FormTemplate>
                            <uc1:UploadControl ID="UploadControl1" runat="server" OnUpload="UploadControl1_Upload" />
                        </FormTemplate></pre>
<p>(please note that the syntax highlighter I am using mangled the code by changing OnUpload to be onupload in the above source) and adding the handler to the main page:</p>
<pre class="brush:csharp">
        protected void UploadControl1_Upload()
        {
            RadGrid1.MasterTableView.IsItemInserted = false;
            RadGrid1.Rebind();
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://microsoft.productiveedge.com/creating-a-telerik-radupload-user-control-for-use-in-a-radgrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
