<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>StuffThatJustWorks.com</title>
    <link>http://www.stuffthatjustworks.com/</link>
    <description>Cal Zant's Blog</description>
    <language>en-us</language>
    <copyright>Cal Zant</copyright>
    <lastBuildDate>Fri, 20 Jul 2012 19:58:29 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>calzant@gmail.com</managingEditor>
    <webMaster>calzant@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=18ee3740-1a6e-49c7-84e3-606399bda4d9</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,18ee3740-1a6e-49c7-84e3-606399bda4d9.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This bugged me for a long time before I stumbled on this hidden trick. It's really
simple to setup, and a real time-saver. 
</p>
        <img border="0" src="http://www.stuffthatjustworks.com/content/binary/Setting-Firefox-to-Allow-Pass-Through-Authentication-to-A-Windows-Authenticated-Site1.png" alt="Firefox's network.automatic-ntlm-auth.trusted-uris Setting" />
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=18ee3740-1a6e-49c7-84e3-606399bda4d9" />
      </body>
      <title>How To: Configure Firefox To Automatically Sign Into Windows Auth Sites</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,18ee3740-1a6e-49c7-84e3-606399bda4d9.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToConfigureFirefoxToAutomaticallySignIntoWindowsAuthSites.aspx</link>
      <pubDate>Fri, 20 Jul 2012 19:58:29 GMT</pubDate>
      <description>&lt;p&gt;
This bugged me for a long time before I stumbled on this hidden trick. It's really
simple to setup, and a real time-saver. 
&lt;/p&gt;
&lt;img border="0" src="http://www.stuffthatjustworks.com/content/binary/Setting-Firefox-to-Allow-Pass-Through-Authentication-to-A-Windows-Authenticated-Site1.png" alt="Firefox's network.automatic-ntlm-auth.trusted-uris Setting"&gt;&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=18ee3740-1a6e-49c7-84e3-606399bda4d9" /&gt;</description>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=18502c2f-ebcc-4e35-bd7e-e8cabedc5497</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,18502c2f-ebcc-4e35-bd7e-e8cabedc5497.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I found this neat little T-SQL trick recently that was really useful. It is essentially
a way to perform a conditional aggregate (i.e. SUM, COUNT, AVG, etc) in MS SQL Server
2008 using a nested CASE statement. Here is an example of how to use it based on the
old Northwind database (yes ... Northwind, keepin' it real). 
</p>
        <img src="http://www.stuffthatjustworks.com/content/binary/Conditional Aggregate T-SQL Example.png" alt="Conditional Aggregate T-SQL Example" />
        <p style="font-family:Courier New;" class="code">
        </p>
        <pre>
SELECT  SUM(UnitsInStock) AS TotalInventory,
        SUM(CASE
		WHEN UnitPrice &gt; 20 THEN 1
		ELSE 0
	    END) AS TotalInventoryOfItemsWithPriceOver20
FROM	Products
</pre>
        <p>
Just in case you don't remember what the Northwind products data looked like, here
is an example of the underlying data this query is running against: 
</p>
        <img src="http://www.stuffthatjustworks.com/content/binary/Northwind Products Data.png" />
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=18502c2f-ebcc-4e35-bd7e-e8cabedc5497" />
      </body>
      <title>How To Use Conditional Aggregates In T-SQL</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,18502c2f-ebcc-4e35-bd7e-e8cabedc5497.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToUseConditionalAggregatesInTSQL.aspx</link>
      <pubDate>Thu, 29 Mar 2012 15:00:31 GMT</pubDate>
      <description>&lt;p&gt;
I found this neat little T-SQL trick recently that was really useful. It is essentially
a way to perform a conditional aggregate (i.e. SUM, COUNT, AVG, etc) in MS SQL Server
2008 using a nested CASE statement. Here is an example of how to use it based on the
old Northwind database (yes ... Northwind, keepin' it real). 
&lt;/p&gt;
&lt;img src="http://www.stuffthatjustworks.com/content/binary/Conditional Aggregate T-SQL Example.png" alt="Conditional Aggregate T-SQL Example"&gt; 
&lt;p style="font-family:Courier New;" class="code"&gt;
&lt;pre&gt;
SELECT  SUM(UnitsInStock) AS TotalInventory,
        SUM(CASE
		WHEN UnitPrice &gt; 20 THEN 1
		ELSE 0
	    END) AS TotalInventoryOfItemsWithPriceOver20
FROM	Products
&lt;/pre&gt;
&gt;
&lt;p&gt;
Just in case you don't remember what the Northwind products data looked like, here
is an example of the underlying data this query is running against: 
&lt;/p&gt;
&lt;img src="http://www.stuffthatjustworks.com/content/binary/Northwind Products Data.png"&gt;&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=18502c2f-ebcc-4e35-bd7e-e8cabedc5497" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=28c68354-e85b-4037-81dd-e6103a0120cb</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,28c68354-e85b-4037-81dd-e6103a0120cb.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was stuck on this for a while, because a Google search didn’t really turn up anything
relevant for this. I essentially had a report containing many subreports. The base
report had a multivalue parameter that I wanted to pass down to each of the subreports,
so they displayed the data to match the selected parameter. 
</p>
        <p>
Here is how the multivalue report parameter was configured on the top-level report: 
</p>
        <img src="http://www.stuffthatjustworks.com/content/binary/Report Parameter Properties for Multivalue.png" alt="Report Parameter Properties for Multivalue" />
        <p>
Passing standard, single-value parameters to subreports is typically very straight-forward.
You can just drop the subreport on the page, right-click on it, go to <strong>Subreport
Properties…</strong>, and click on the <strong>Parameters</strong> section. Here is
a basic example of how you would pass two simple date parameters to the subreport
(they have identical names on both the parent and subreport): 
</p>
        <img src="http://www.stuffthatjustworks.com/content/binary/Typical Way To Pass Parameters To Subreports.png" alt="Typical Way To Pass Parameters To Subreports" />
        <p>
However, you can’t do that with a multi-value parameter. I eventually learned the
trick is related to how the values are serialized and so they are presented to the
subreport in the expected format. Essentially it must be passed as an array of strings
if you want the subreport to understand it, and you need to write a short expression
to do that: 
</p>
        <img src="http://www.stuffthatjustworks.com/content/binary/Subreport Properties with Serialized Values.png" alt="Subreport Properties with Serialized Values" />
        <p>
=Split(Join(Parameters!RegionIDs.Value,","),",") 
</p>
        <p>
We will break down what the script is doing and why it works: 
</p>
        <ol>
          <li>
            <strong>Parameters!RegionIDs.Value</strong> = By default this call by itself will
result in an error (yeah, not what you might expect). If you tried something like
Parameters!RegionIDs.Value(0) it would work, but you would only get the first value
selected and if none were selected you would get an error. Apparently at this level
the value is pretty useless, but stick with me. 
</li>
          <li>
            <strong>Join(--Results From #1--,",")</strong> = This will essentially convert whatever
the original data type was into a comma-separated string of the selected values. Since
my example was a bunch of integers, the value of this statement might produce something
like “1,2,6”. 
</li>
          <li>
            <strong>Split(--Results From #2--,",")</strong> = This will convert convert that comma-separated
string (e.g. “1,2,6”) back out into an array, but this time it is an array of strings.
I’m not sure what the data type was of the original array, but apparently it wasn’t
something the subreport report was expecting. But by converting it to an array of
strings, the subreport should work as expected now. 
</li>
        </ol>
        <p>
Here is a good resource for more info on using parameters: <a href="http://technet.microsoft.com/en-us/library/dd207127(v=sql.100).aspx">http://technet.microsoft.com/en-us/library/dd207127(v=sql.100).aspx</a></p>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=28c68354-e85b-4037-81dd-e6103a0120cb" />
      </body>
      <title>How To Pass Multivalue Report Parameters To Subreports In Report Builder</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,28c68354-e85b-4037-81dd-e6103a0120cb.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToPassMultivalueReportParametersToSubreportsInReportBuilder.aspx</link>
      <pubDate>Wed, 28 Mar 2012 23:57:48 GMT</pubDate>
      <description>    &lt;p&gt;
I was stuck on this for a while, because a Google search didn’t really turn up anything
relevant for this. I essentially had a report containing many subreports. The base
report had a multivalue parameter that I wanted to pass down to each of the subreports,
so they displayed the data to match the selected parameter. 
&lt;/p&gt;
&lt;p&gt;
Here is how the multivalue report parameter was configured on the top-level report: 
&lt;/p&gt;
&lt;img src="http://www.stuffthatjustworks.com/content/binary/Report Parameter Properties for Multivalue.png" alt="Report Parameter Properties for Multivalue"&gt; 
&lt;p&gt;
Passing standard, single-value parameters to subreports is typically very straight-forward.
You can just drop the subreport on the page, right-click on it, go to &lt;strong&gt;Subreport
Properties…&lt;/strong&gt;, and click on the &lt;strong&gt;Parameters&lt;/strong&gt; section. Here is
a basic example of how you would pass two simple date parameters to the subreport
(they have identical names on both the parent and subreport): 
&lt;/p&gt;
&lt;img src="http://www.stuffthatjustworks.com/content/binary/Typical Way To Pass Parameters To Subreports.png" alt="Typical Way To Pass Parameters To Subreports"&gt; 
&lt;p&gt;
However, you can’t do that with a multi-value parameter. I eventually learned the
trick is related to how the values are serialized and so they are presented to the
subreport in the expected format. Essentially it must be passed as an array of strings
if you want the subreport to understand it, and you need to write a short expression
to do that: 
&lt;/p&gt;
&lt;img src="http://www.stuffthatjustworks.com/content/binary/Subreport Properties with Serialized Values.png" alt="Subreport Properties with Serialized Values"&gt; 
&lt;p&gt;
=Split(Join(Parameters!RegionIDs.Value,","),",") 
&lt;/p&gt;
&lt;p&gt;
We will break down what the script is doing and why it works: 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Parameters!RegionIDs.Value&lt;/strong&gt; = By default this call by itself will
result in an error (yeah, not what you might expect). If you tried something like
Parameters!RegionIDs.Value(0) it would work, but you would only get the first value
selected and if none were selected you would get an error. Apparently at this level
the value is pretty useless, but stick with me. 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Join(--Results From #1--,",")&lt;/strong&gt; = This will essentially convert whatever
the original data type was into a comma-separated string of the selected values. Since
my example was a bunch of integers, the value of this statement might produce something
like “1,2,6”. 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split(--Results From #2--,",")&lt;/strong&gt; = This will convert convert that comma-separated
string (e.g. “1,2,6”) back out into an array, but this time it is an array of strings.
I’m not sure what the data type was of the original array, but apparently it wasn’t
something the subreport report was expecting. But by converting it to an array of
strings, the subreport should work as expected now. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Here is a good resource for more info on using parameters: &lt;a href="http://technet.microsoft.com/en-us/library/dd207127(v=sql.100).aspx"&gt;http://technet.microsoft.com/en-us/library/dd207127(v=sql.100).aspx&lt;/a&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=28c68354-e85b-4037-81dd-e6103a0120cb" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=2d59b0a4-a5b9-4e60-9982-8f95151adf00</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,2d59b0a4-a5b9-4e60-9982-8f95151adf00.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I ran into this issue a few times, and finally decided to figure out what was going
on.  Apparently in SQL Server 2008 they made some changes to the default behavior
of the designer, so that it didn't apply any changes that required a table to recreated. 
This was primarily changed because when a change is made that does
require the table to be recreated, SQL has to copy all of the data already
in that table to a temporary location, recreate the table with the new
changes applied, and then copy the data back over from the temporary location. 
If the table contains a large amount of data this can take some time, and essentially
freezes up management studio while it executes.  So their fix was to just
make that behavior disabled by default, and require users to opt-in if they
needed it.
</p>
        <p>
Here is the error message window it shows when this is your problem:
</p>
        <blockquote style="MARGIN-RIGHT: 0px" dir="ltr">
          <p>
            <em>Saving changes is not permitted.  The changes you have made require the following
tables to be dropped and re-created.  You have either made changes to a table
that can't be re-created or enabled the option Prevent saving changes that require
the table to be re-created.</em>
          </p>
          <p>
            <img border="0" src="http://www.stuffthatjustworks.com/content/binary/SQL 2008 Alert Error Message saving changes is not permitted enabled the option prevent saving changes.png" />
          </p>
        </blockquote>
        <p>
The fix is to just go disable that option, and to do that you just go to <strong>Tools
&gt; Options</strong> in SQL Management Studio.  Then click on the <strong>Designer</strong> section.
</p>
        <p>
          <img border="0" src="http://www.stuffthatjustworks.com/content/binary/SQL 2008 enabled the option prevent saving changes that require table re-creation.png" />
        </p>
        <p>
Unselect the checkbox with the text "Prevent saving changes that require table re-creation"
as shown above, and click <strong>OK</strong>.  Try to re-save the changes to
your table, and it should work.
</p>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=2d59b0a4-a5b9-4e60-9982-8f95151adf00" />
      </body>
      <title>How To Fix: SQL 2008 Error - Saving changes is not permitted.  You have enabled the option to Prevent saving changes that require the table to re-created.</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,2d59b0a4-a5b9-4e60-9982-8f95151adf00.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToFixSQL2008ErrorSavingChangesIsNotPermittedYouHaveEnabledTheOptionToPreventSavingChangesThatRequireTheTableToRecreated.aspx</link>
      <pubDate>Tue, 21 Dec 2010 20:15:57 GMT</pubDate>
      <description>&lt;p&gt;
I ran into this issue a few times, and finally decided to figure out what was going
on.&amp;nbsp; Apparently in SQL Server 2008 they made some changes to the default behavior
of the designer, so that it didn't apply any changes that required a table to recreated.&amp;nbsp;
This was primarily&amp;nbsp;changed because&amp;nbsp;when&amp;nbsp;a change is made that does
require&amp;nbsp;the table to be recreated, SQL has to copy all&amp;nbsp;of the data already
in that table to a temporary location,&amp;nbsp;recreate the table&amp;nbsp;with the&amp;nbsp;new
changes applied, and then copy the data back over from the temporary location.&amp;nbsp;
If the table contains a large amount of data this can take some time, and essentially
freezes up&amp;nbsp;management studio while it executes.&amp;nbsp; So their fix was to just
make&amp;nbsp;that&amp;nbsp;behavior disabled by default, and require users to opt-in if they
needed it.
&lt;/p&gt;
&lt;p&gt;
Here is the error message window it shows when this is your problem:
&lt;/p&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir=ltr&gt; 
&lt;p&gt;
&lt;em&gt;Saving changes is not permitted.&amp;nbsp; The changes you have made require the following
tables to be dropped and re-created.&amp;nbsp; You have either made changes to a table
that can't be re-created or enabled the option Prevent saving changes that require
the table to be re-created.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://www.stuffthatjustworks.com/content/binary/SQL 2008 Alert Error Message saving changes is not permitted enabled the option prevent saving changes.png"&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The fix is to just go disable that option, and to do that you just go to &lt;strong&gt;Tools
&amp;gt; Options&lt;/strong&gt; in SQL Management Studio.&amp;nbsp; Then click on the &lt;strong&gt;Designer&lt;/strong&gt; section.
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://www.stuffthatjustworks.com/content/binary/SQL 2008 enabled the option prevent saving changes that require table re-creation.png"&gt;
&lt;/p&gt;
&lt;p&gt;
Unselect the checkbox with the text "Prevent saving changes that require table re-creation"
as shown above, and click &lt;strong&gt;OK&lt;/strong&gt;.&amp;nbsp; Try to re-save the changes to
your table, and it should work.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=2d59b0a4-a5b9-4e60-9982-8f95151adf00" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=59f69fbb-617c-4ec1-ab07-aad31f23ec7b</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,59f69fbb-617c-4ec1-ab07-aad31f23ec7b.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the biggest drawbacks of using ASP.NET is the way it can really bloat a page
size with ViewState.  That is because http and the web in general are
stateless by nature, but when creating applications developers often need to
track what changed on a form ... hence ViewState was introduced to essentially
let the development code as if the web was stateful.  Although some left-wing
purist might argue, my more pragmatic nature causes me to think this was
a good thing overall because of the dramatic increase in productivity it offers. 
However, the downside was bloated pages to the client ... but now ASP.NET 4.0 offers
a better way to control that.
</p>
        <p>
Pre 4.0, ASP.NET offered the EnableViewState property which you could put on a page
or control.  If you set that value to false, it disabled all viewstate for that
control and any child controls.  The problem was you didn't have the ability
to override that behavior in any of the child controls.  So this was more
of a system where it had to be enabled at a high level, but then disabled in an opt-out
fashion where you didn't really need it.  The result was that people just didn't
opt-out.  That isn't because they were lazy (well, not completely) ... its just
that pattern doesn't encourage good practices.
</p>
        <p>
ASP.NET 4.0 includes a new ViewStateMode property that is completely different than
EnableViewState.  It allows you to set the overall viewstate for a site off by
default, but that can be overridden at any level below that.  This creates an
opt-in pattern.  When I first tried to confige this setup, I ran into a few problems
because I was trying to mix EnableViewState with ViewStateMode.<strong></strong><strong>EnableViewState
always trumps the ViewStateMode setting.  I think it is much simpler to
not mix the two and just avoid the old school EnableViewState property all
together, and solely rely on ViewStateMode to control your ViewState.</strong></p>
        <h2>The ViewState Opt-In Pattern Using ViewStateMode
</h2>
        <ol>
          <li>
Set the site's masterpage(s) to have a ViewStateMode setting of "Disabled". 
Unfortunately you can't set that property at the page level in the web.config, but
disabling at the master page level should have a similar site-wide effect.<br /><br /><font face="Courier New">&lt;%@ Master Language="C#" ViewStateMode="Disabled" ...</font><br /><br />
You could optionally set the ViewStateMode="Disabled" on one or more of the content
placeholders in your master page:<br /><br /><font face="Courier New">&lt;asp:ContentPlaceHolder ID="ContentPlaceHolder1" ViewStateMode="Disabled"
...</font><br /></li>
          <li>
Then, when you need viewstate on a certain page or control ... just set ViewStateMode="Enabled"
at that location.  It is usually very obvious when you need this when you are
developing the site from scratch, but this type of pattern can be more difficult to
retro-fit into an existing app.  Essentially the things that typically need ViewState
are controls that you will need to access the values of on a PostBack to the server
(e.g. textboxes, drop downs, checkboxes, etc).<br /><br />
One tricky thing I have ran into is that you can't set the ViewStateMode at the page
level in the Page directive like this (at least when using master pages):<br /><br /><font face="Courier New">&lt;%@ Page Title="Dynamic Schedule" ViewStateMode="Enabled"
... <strong><font color="#ff0000">// WON'T WORK<br /></font></strong></font><br />
Instead you should preferrably set it for the individual controls that need it that
way only the ViewState data that is required would be sent to/from the client, and
the page wouldn't be bloated with unnecessary ViewState data.<br /><br /><font face="Courier New">&lt;asp:CheckBoxList ID="cblProducts" ViewStateMode="Enabled"
...</font><br /><br />
If you have many controls that you need to enable ViewState on, and you didn't want
to have to set the property on all of them ... you could optionally just enable
viewstate for an entire content placeholder section like this:<br /><br /><font face="Courier New">&lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
ViewStateMode="Enabled" ...</font></li>
        </ol>
        <p>
Here are a few more helpful resources on the new ViewStateMode functionality:
</p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.viewstatemode.aspx">http://msdn.microsoft.com/en-us/library/system.web.ui.viewstatemode.aspx</a>
          <br />
          <a href="http://weblogs.asp.net/sreejukg/archive/2010/04/06/viewstatemode-in-asp-net-4-0.aspx">http://weblogs.asp.net/sreejukg/archive/2010/04/06/viewstatemode-in-asp-net-4-0.aspx</a>
          <br />
          <a href="http://www.mostlylucid.net/archive/2009/01/28/1312.aspx">http://www.mostlylucid.net/archive/2009/01/28/1312.aspx</a>
        </p>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=59f69fbb-617c-4ec1-ab07-aad31f23ec7b" />
      </body>
      <title>How To: Control Your ViewState in ASP.NET 4.0 (EnableViewState vs. ViewStateMode)</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,59f69fbb-617c-4ec1-ab07-aad31f23ec7b.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToControlYourViewStateInASPNET40EnableViewStateVsViewStateMode.aspx</link>
      <pubDate>Fri, 23 Jul 2010 20:06:36 GMT</pubDate>
      <description>&lt;p&gt;
One of the biggest drawbacks of using ASP.NET is the way it can really bloat a page
size&amp;nbsp;with ViewState.&amp;nbsp; That is because http and&amp;nbsp;the web in general&amp;nbsp;are
stateless&amp;nbsp;by nature, but when creating applications developers often need to
track what changed on a form&amp;nbsp;... hence ViewState was introduced to essentially
let the development code as if&amp;nbsp;the web was stateful.&amp;nbsp; Although some left-wing
purist might&amp;nbsp;argue, my more&amp;nbsp;pragmatic nature causes me to think this was
a good thing overall because&amp;nbsp;of the dramatic increase in productivity it offers.&amp;nbsp;
However, the downside was bloated pages to the client ... but now ASP.NET 4.0 offers
a better way to control that.
&lt;/p&gt;
&lt;p&gt;
Pre 4.0, ASP.NET offered the EnableViewState property which you could put on a page
or control.&amp;nbsp; If you set that value to false, it disabled all viewstate for that
control and any child controls.&amp;nbsp; The problem was you didn't have the ability
to override that behavior in any of the child controls.&amp;nbsp; So this was&amp;nbsp;more
of a system where it had to be enabled at a high level, but then disabled in an opt-out
fashion where you didn't really need it.&amp;nbsp; The result was that people just didn't
opt-out.&amp;nbsp; That isn't because they were lazy (well, not completely) ... its just
that pattern doesn't encourage good practices.
&lt;/p&gt;
&lt;p&gt;
ASP.NET 4.0 includes a new ViewStateMode property that is completely different than
EnableViewState.&amp;nbsp; It allows you to set the overall viewstate for a site off by
default, but that can be overridden at any level below that.&amp;nbsp; This creates an
opt-in pattern.&amp;nbsp; When I first tried to confige this setup, I ran into a few problems
because I was trying to mix EnableViewState with ViewStateMode.&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt;EnableViewState
always trumps the ViewStateMode setting.&amp;nbsp; I think it is much&amp;nbsp;simpler to
not mix the two and&amp;nbsp;just avoid the old school&amp;nbsp;EnableViewState property&amp;nbsp;all
together, and solely rely on ViewStateMode to control your ViewState.&lt;/strong&gt;
&lt;/p&gt;
&lt;h2&gt;The ViewState Opt-In Pattern Using ViewStateMode
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
Set the site's masterpage(s) to have a ViewStateMode setting of "Disabled".&amp;nbsp;
Unfortunately you can't set that property at the page level in the web.config, but
disabling at the master page level should have a similar site-wide effect.&lt;br&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;lt;%@ Master Language="C#" ViewStateMode="Disabled" ...&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
You could optionally set the ViewStateMode="Disabled" on one or more of the content
placeholders in your master page:&lt;br&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;lt;asp:ContentPlaceHolder ID="ContentPlaceHolder1" ViewStateMode="Disabled"
...&lt;/font&gt;
&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
Then, when you need viewstate on a certain page or control ... just set ViewStateMode="Enabled"
at that location.&amp;nbsp; It is usually very obvious when you need this when you are
developing the site from scratch, but this type of pattern can be more difficult to
retro-fit into an existing app.&amp;nbsp; Essentially the things that typically need ViewState
are controls that you will need to access the values of on a PostBack to the server
(e.g. textboxes, drop downs, checkboxes, etc).&lt;br&gt;
&lt;br&gt;
One tricky thing I have ran into is that you can't set the ViewStateMode at the page
level&amp;nbsp;in the Page directive like this (at least when using master pages):&lt;br&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;lt;%@ Page Title="Dynamic Schedule" ViewStateMode="Enabled"
... &lt;strong&gt;&lt;font color=#ff0000&gt;// WON'T WORK&lt;br&gt;
&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;
&lt;br&gt;
Instead you should preferrably set it for the individual controls that need it that
way only the ViewState data that is required would be sent to/from the client, and
the page wouldn't be bloated with unnecessary&amp;nbsp;ViewState data.&lt;br&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;lt;asp:CheckBoxList ID="cblProducts" ViewStateMode="Enabled"
...&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
If you have many controls that you need to enable ViewState on, and you didn't want
to have to set the property on all of them ...&amp;nbsp;you could optionally just enable
viewstate for an entire content placeholder section like this:&lt;br&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
ViewStateMode="Enabled" ...&lt;/font&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Here are a few more helpful resources on&amp;nbsp;the new&amp;nbsp;ViewStateMode functionality:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.viewstatemode.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.web.ui.viewstatemode.aspx&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://weblogs.asp.net/sreejukg/archive/2010/04/06/viewstatemode-in-asp-net-4-0.aspx"&gt;http://weblogs.asp.net/sreejukg/archive/2010/04/06/viewstatemode-in-asp-net-4-0.aspx&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://www.mostlylucid.net/archive/2009/01/28/1312.aspx"&gt;http://www.mostlylucid.net/archive/2009/01/28/1312.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=59f69fbb-617c-4ec1-ab07-aad31f23ec7b" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=9b99c723-3660-4b3d-ad8f-6f6247886860</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,9b99c723-3660-4b3d-ad8f-6f6247886860.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a T-SQL code snippet I find myself using regularly to find all references
to a particular field or table, or search for comments from a particular date. 
It essentially allows you to search for a keyword in all of the definitions for stored
procedures, functions (scalar or table-valued), and views.  It uses some of the
built-in methods SQL Server provides for obtaining metadata, which are essentially
simplified views of the data contained in system tables like sysobjects and syscolumns. 
I know this T-SQL script works on SQL Server 2005 &amp; SQL Server 2008, but
don't know if the methods it is dependent on were available on previous versions.
</p>
        <p>
          <font face="Courier New">
            <strong>DECLARE @Keyword varchar(64)<br />
SET @Keyword = '%keyword%'</strong>
          </font>
        </p>
        <p>
          <font face="Courier New">
            <strong>(<br />
  SELECT  [ROUTINE_TYPE] AS 'Type', [SPECIFIC_NAME] AS 'Name'<br />
  FROM  INFORMATION_SCHEMA.ROUTINES<br />
  WHERE  [ROUTINE_DEFINITION] LIKE @Keyword<br />
 UNION<br />
  SELECT  'VIEW' AS 'Type', [TABLE_NAME] AS 'Name'<br />
  FROM  INFORMATION_SCHEMA.VIEWS<br />
  WHERE  [VIEW_DEFINITION] LIKE @Keyword<br />
)<br />
ORDER BY [Type], [Name]</strong>
          </font>
        </p>
        <p>
Here is an example of the results of the script:
</p>
        <img border="0" alt="Search Results of All SQL Defintions for Stored Procedures, Functions, &amp; Views" src="http://www.stuffthatjustworks.com/content/binary/Search Results of T-SQL Script.png" />
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=9b99c723-3660-4b3d-ad8f-6f6247886860" />
      </body>
      <title>How To: Search Definitions of All SQL Procedures, Functions, &amp; Views Using T-SQL</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,9b99c723-3660-4b3d-ad8f-6f6247886860.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToSearchDefinitionsOfAllSQLProceduresFunctionsViewsUsingTSQL.aspx</link>
      <pubDate>Tue, 13 Apr 2010 12:45:29 GMT</pubDate>
      <description>&lt;p&gt;
This is a T-SQL&amp;nbsp;code snippet I find myself using regularly to find all references
to a particular field or table, or&amp;nbsp;search for comments from a particular date.&amp;nbsp;
It essentially allows you to search for a keyword in all of the definitions for stored
procedures, functions (scalar or table-valued), and views.&amp;nbsp; It uses some of the
built-in methods SQL Server provides for obtaining metadata, which are essentially
simplified views of the data contained in system tables like sysobjects and syscolumns.&amp;nbsp;
I know this T-SQL script works&amp;nbsp;on SQL Server 2005 &amp;amp; SQL Server 2008, but
don't know if the methods it is dependent on&amp;nbsp;were available on previous versions.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;DECLARE @Keyword varchar(64)&lt;br&gt;
SET @Keyword = '%keyword%'&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;(&lt;br&gt;
&amp;nbsp;&amp;nbsp;SELECT&amp;nbsp;&amp;nbsp;[ROUTINE_TYPE] AS 'Type', [SPECIFIC_NAME] AS 'Name'&lt;br&gt;
&amp;nbsp;&amp;nbsp;FROM&amp;nbsp;&amp;nbsp;INFORMATION_SCHEMA.ROUTINES&lt;br&gt;
&amp;nbsp;&amp;nbsp;WHERE&amp;nbsp;&amp;nbsp;[ROUTINE_DEFINITION] LIKE @Keyword&lt;br&gt;
&amp;nbsp;UNION&lt;br&gt;
&amp;nbsp;&amp;nbsp;SELECT&amp;nbsp;&amp;nbsp;'VIEW' AS 'Type', [TABLE_NAME] AS 'Name'&lt;br&gt;
&amp;nbsp;&amp;nbsp;FROM&amp;nbsp;&amp;nbsp;INFORMATION_SCHEMA.VIEWS&lt;br&gt;
&amp;nbsp;&amp;nbsp;WHERE&amp;nbsp;&amp;nbsp;[VIEW_DEFINITION] LIKE @Keyword&lt;br&gt;
)&lt;br&gt;
ORDER BY [Type], [Name]&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Here is an example of the results of the script:
&lt;/p&gt;
&lt;img border=0 alt="Search Results of All SQL Defintions for Stored Procedures, Functions, &amp;amp; Views" src="http://www.stuffthatjustworks.com/content/binary/Search Results of T-SQL Script.png"&gt;&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=9b99c723-3660-4b3d-ad8f-6f6247886860" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=187f22ee-fd26-466b-8d5e-073b40eb3809</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,187f22ee-fd26-466b-8d5e-073b40eb3809.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
During my career, I have written a few components that used colors to visually encode
data.  Recently I found myself looking at a color chart and trying to choose
colors that were easy to distinguish from one another ... again.  It seems like
I have done that a few times during my career, so this time I wanted to put it to
bed for good.  Instead of relying on my unscientific approach, I figured this
had to be a problem that someone solved before ... and Excel came to mind.
</p>
        <p>
When you create a chart in Excel, it automatically assigns each series a different
color.  Microsoft almost certainly poured a ton of research/money into this same
problem I was trying to solve:
</p>
        <blockquote style="MARGIN-RIGHT: 0px" dir="ltr">
          <h3>Which set of colors are easiest to differentiate from one another?
</h3>
        </blockquote>
        <p>
They probably also took visual disabilities into account, like color blindness (which
I have) and poor vision.  So why reinvent the wheel with this stuff?  Here
is a pie chart that displays default color series Excel 2007 automatically assigned
to a simple pie chart, which includes the HEX and RGB values for each series color:
</p>
        <p>
          <img border="0" alt="Default Excel Color Series Easy Colors To Tell Apart" src="http://www.stuffthatjustworks.com/content/binary/Default%20Excel%20Color%20Series.png" />
        </p>
        <p>
          <strong>A few things to keep in mind</strong>
        </p>
        <ul>
          <li>
Here is an helpful excerpt from <a href="http://www.amazon.com/dp/0596100167">Information
Dashboard Design</a> (a very research driven book) on this topic: <em><font color="#808080" size="3">"When
organizing data into distinct groups using different expressions of any preattentive
attribute, you should be careful not to exceed five distinct expressions. ... <strong>When
using hue, keep in mind that even though we can easily distinguish more than five
hues, short-term memory can't simultaneously retain the meaning of more than about
nine in total.</strong>"</font></em></li>
          <li>
When using colors to visual encode information, think about what it would look like
if printed in black and white.  Would you still be able to distinguish between
the different series or groups, or would that encoding be lost without color?  Although
the project you are working on may never be printed black and white, almost
10% of males have some type of color blindness ... so thinking through this
scenario can help you understand their perspective.  Usually adding a label
(like the numbers in the example above) or patterns (e.g. stripes) in addition
to color would be enough to enable someone to make sense of the encoding, even if
they aren't able to process it preattentively like the color coding.</li>
        </ul>
        <p>
Here is a C# code snippet that I use, which returns a list of the related
colors outlined above:
</p>
        <p>
          <font face="Courier New">
            <font color="#006400">/// &lt;summary&gt;<br />
/// Returns a list of colors derived from the defaults Excel uses for chart series.<br />
/// These colors should be very easy to differentiate from one another.<br />
/// &lt;/summary&gt;</font>
            <br />
            <strong>public static List&lt;Color&gt; DefaultExcelColors<br />
{<br />
    get<br />
    {<br />
        return new List&lt;Color&gt;()<br />
            {<br />
               
Color.FromArgb(69,114,167),<br />
               
Color.FromArgb(170,70,67),<br />
               
Color.FromArgb(137,165,78),<br />
               
Color.FromArgb(113,88,143),<br />
               
Color.FromArgb(65,152,175),<br />
               
Color.FromArgb(219,132,61),<br />
               
Color.FromArgb(147,169,207),<br />
               
Color.FromArgb(209,147,146),<br />
               
Color.FromArgb(185,205,150),<br />
               
Color.FromArgb(169,155,189)<br />
            };<br />
    }<br />
}</strong>
          </font>
        </p>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=187f22ee-fd26-466b-8d5e-073b40eb3809" />
      </body>
      <title>Default Excel Chart Colors - Easy Colors To Tell Apart</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,187f22ee-fd26-466b-8d5e-073b40eb3809.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/DefaultExcelChartColorsEasyColorsToTellApart.aspx</link>
      <pubDate>Tue, 06 Apr 2010 12:50:28 GMT</pubDate>
      <description>&lt;p&gt;
During my career, I have written a few components that used colors to visually encode
data.&amp;nbsp; Recently I found&amp;nbsp;myself looking at a color chart and trying to choose
colors that were easy to distinguish from one another ... again.&amp;nbsp; It seems like
I have done that a few times during my career, so this time I wanted to put it to
bed for good.&amp;nbsp; Instead of relying on my unscientific approach, I figured this
had to be a problem that someone solved before ... and Excel came to mind.
&lt;/p&gt;
&lt;p&gt;
When you create a chart in Excel, it automatically assigns each series a different
color.&amp;nbsp; Microsoft almost certainly poured a ton of research/money into this same
problem I was trying to solve:
&lt;/p&gt;
&lt;blockquote style="MARGIN-RIGHT: 0px" dir=ltr&gt; 
&lt;h3&gt;Which set of colors are easiest to differentiate from one another?
&lt;/h3&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
They probably also took visual disabilities into account, like color blindness (which
I have) and poor vision.&amp;nbsp; So why reinvent the wheel with this stuff?&amp;nbsp; Here
is a pie chart that displays default color series&amp;nbsp;Excel 2007 automatically assigned
to a simple pie chart, which&amp;nbsp;includes the HEX and RGB&amp;nbsp;values for each series&amp;nbsp;color:
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 alt="Default Excel Color Series Easy Colors To Tell Apart" src="http://www.stuffthatjustworks.com/content/binary/Default%20Excel%20Color%20Series.png"&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;A few things to keep in mind&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Here is an helpful&amp;nbsp;excerpt from &lt;a href="http://www.amazon.com/dp/0596100167"&gt;Information
Dashboard Design&lt;/a&gt; (a very research driven book)&amp;nbsp;on this topic: &lt;em&gt;&lt;font color=#808080 size=3&gt;"When
organizing data into distinct groups using different expressions of any preattentive
attribute, you should be careful not to exceed five distinct expressions. ... &lt;strong&gt;When
using hue, keep in mind that even though we can easily distinguish more than five
hues, short-term memory can't simultaneously retain the meaning of more than about
nine in total.&lt;/strong&gt;"&lt;/font&gt;&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
When using colors to visual encode information, think about what it would look like
if printed in black and white.&amp;nbsp; Would you still be able to&amp;nbsp;distinguish between
the different series or groups, or would that encoding&amp;nbsp;be lost&amp;nbsp;without color?&amp;nbsp;&amp;nbsp;Although
the project you are working on may&amp;nbsp;never be printed&amp;nbsp;black and white,&amp;nbsp;almost
10% of&amp;nbsp;males&amp;nbsp;have some type of color blindness ... so thinking through this
scenario can help you understand their perspective.&amp;nbsp; Usually adding a&amp;nbsp;label
(like the numbers in the example above) or patterns (e.g. stripes)&amp;nbsp;in addition
to color would be enough to enable someone to make sense of the encoding, even if
they aren't able to process it preattentively like the color coding.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Here is a C#&amp;nbsp;code snippet that I&amp;nbsp;use, which returns a list of the related
colors outlined above:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;font color=#006400&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Returns a list of colors derived from the defaults Excel uses for chart series.&lt;br&gt;
/// These colors should be very easy to differentiate from one another.&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;/font&gt;
&lt;br&gt;
&lt;strong&gt;public static List&amp;lt;Color&amp;gt; DefaultExcelColors&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new List&amp;lt;Color&amp;gt;()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(69,114,167),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(170,70,67),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(137,165,78),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(113,88,143),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(65,152,175),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(219,132,61),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(147,169,207),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(209,147,146),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(185,205,150),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Color.FromArgb(169,155,189)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=187f22ee-fd26-466b-8d5e-073b40eb3809" /&gt;</description>
      <category>Code</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=5d1e5dfa-ca14-4e9e-afff-c227e83b02d7</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,5d1e5dfa-ca14-4e9e-afff-c227e83b02d7.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A few weeks ago, I started noticing that every time I opened a LINQ to SQL .dbml file
in Visual Studio 2008 I would get an alert message that said <em>"The connection property
in the web.config file is missing or incorrect.  The connection string from the
.dbml file has been used in its place."</em></p>
        <p>
          <img border="0" alt="The connection property in the web.config file is missing or incorrect" src="http://www.stuffthatjustworks.com/content/binary/Connection%20Property%20in%20the%20web.config%20is%20missing%20or%20incorrect.png" />
        </p>
        <p>
The dbml file was configured to reference a connection string in the web.config file,
but after I got this alert and clicked OK, Visual Studio would check out the project
and add a new Settings.settings file under the Properties folder and generate a new
connection string there, and then change the dbml file to reference that instead of
the web.config.
</p>
        <p>
          <img border="0" alt="Changes that were automatically applied to the project after I clicked OK" src="http://www.stuffthatjustworks.com/content/binary/New%20Settings%20File.png" />
        </p>
        <p>
This would probably be the behavior you would expect if the web.config was really
missing the connection string, but in my case the referenced connection string was
there and well-formed.  I know this, because the related code was under
source control and other developers could open the same dbml file (from the
shared code base) and they wouldn't get the alert and everything worked
flawlessly.
</p>
        <p>
To me, it seemed like the LINQ to SQL designer on my machine was simply having trouble
reading from the configuration file ... so I thought it might be an issue with a particular
dll or registry entry.  Another thing that convinced me of this was the fact
that when you were in the dbml editor ... under the Connections property on my computer,
none of the connection strings from the web.config were included in the drop down
to select from.  But, when another developer would look at this on their machine
(using the same exact code base and files), their Visual Studio environment would
find those connection strings in the web.config and include them in the list to select
from.
</p>
        <p>
          <img border="0" alt="Connection Options on my computer containing no references to web.config connection strings" src="http://www.stuffthatjustworks.com/content/binary/What%20I%20See%20As%20Connection%20Options%20(Close%20Up).png" />
        </p>
        <p>
          <img border="0" alt="Connection Options on other computers containing references to web.config connection strings" src="http://www.stuffthatjustworks.com/content/binary/What%20Other%20Developers%20See%20As%20Connection%20Options%20(Close%20Up).png" />
        </p>
        <p>
I figured out that I could just undo the changes to add the new file, and then
view the differences of the dbml file's XML and undo the reference change to make
it once again reference the web.config instead of the settings file it created ...
and that worked fine for a couple weeks, but eventually jumping through those extra
hoops that "should just work" got pretty old.
</p>
        <p>
So I first tried to repair my Visual Studio install, but that didn't work.  Next, I
completely uninstalled Visual Studio and then re-installed it and the related service
packs ... but that didn't work either.  I was about to just format my machine
and re-install Windows ... but I thought I would give Microsoft Support
a chance, hoping they could help me.  I knew this was an obscure enough
problem that they probably wouldn't be much help, but I really hate paving my machine
... so it was worth a little time to give them a chance.  After explaining what
was going on to a technician, we tried to use ProcMon to figure out what was going
on behind the scenes.  We noticed several registry errors, and that further convinced
me that the problem was corrupted  or missing registry keys.  The support
technician said he would have to look into it more, but I wasn't going to
count on them as my only hope for a solution ... so I kept investigating myself.  <strong>Apparently
when you uninstall Visual Studio, it doesn't remove all of the registry keys. 
It also doesn't overwrite them all when you run a repair.</strong>  It doesn't
even remove them all when you remove all the other software that might have hooks
or add-ins related to Visual Studio.  So these corrupted or missing registry
keys could have persisted through the repair and re-install.
</p>
        <p>
Here are some of the issues we noticed in ProcMon (it is a snapshot of what was happening
when I would open the dbml file and the pop-up alert would appear, and then I would
click OK).  The one highlighted is the what I was guessing was the culprit, because
that missed registry key occurred right between the read of the dbml file and the
opening the related project (which I am guessing was to create the new settings file). 
You can ignore the "Fast IO Disallowed" stuff, because that is unrelated.
</p>
        <p>
          <img border="0" alt="Related errors from Process Monitor while opening the LINQ to SQL dbml file" src="http://www.stuffthatjustworks.com/content/binary/ProcMon%20Visual%20Studio%20DevEnv%20Registry%20Errors.png" />
        </p>
        <p>
So, although the support technician had actually explicitly advised me <u>not</u> to
do this ... I decided to uninstall Visual Studio (and any other software add-ins that
might be related to it), manually delete the related registry keys contained in any
folder that appeared related to Visual Studio, and then do a fresh install.  <strong>I
never think hacking in the registry is a good solution to a problem, but this was
my last ditch effort ... and I was resolved to do a full re-install of Windows if
it didn't work.  To my surprise ... <u>it actually worked</u>.</strong></p>
        <p>
I can't guarantee this will work for you, or even recommend it ... but here are the
registry folder locations I manually deleted:
</p>
        <ul>
          <li>
            <font face="Courier New">HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio</font>
          </li>
          <li>
            <font face="Courier New">HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio</font>
          </li>
          <li>
            <font face="Courier New">HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSCommon</font>
          </li>
          <li>
            <font face="Courier New">HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSTAHost</font>
          </li>
        </ul>
        <p>
Hopefully if you are still reading, this is the exact problem you are having and this
will work for you as well.  The only thing I can say is ... it worked on my machine,
and it saved me from having to completely re-install Windows to fix the problem.
</p>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=5d1e5dfa-ca14-4e9e-afff-c227e83b02d7" />
      </body>
      <title>How To: Fix LINQ to SQL DBML Issue "The connection property of the web.config file is missing or incorrect"</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,5d1e5dfa-ca14-4e9e-afff-c227e83b02d7.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToFixLINQToSQLDBMLIssueTheConnectionPropertyOfTheWebconfigFileIsMissingOrIncorrect.aspx</link>
      <pubDate>Wed, 20 Jan 2010 15:22:50 GMT</pubDate>
      <description>&lt;p&gt;
A few weeks ago, I started noticing that every time I opened a LINQ to SQL .dbml file
in Visual Studio 2008 I would get an alert message that said &lt;em&gt;"The connection property
in the web.config file is missing or incorrect.&amp;nbsp; The connection string from the
.dbml file has been used in its place."&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 alt="The connection property in the web.config file is missing or incorrect" src="http://www.stuffthatjustworks.com/content/binary/Connection%20Property%20in%20the%20web.config%20is%20missing%20or%20incorrect.png"&gt;
&lt;/p&gt;
&lt;p&gt;
The dbml file was configured to reference a connection string in the web.config file,
but after I got this alert and clicked OK, Visual Studio would check out the project
and add a new Settings.settings file under the Properties folder and generate a new
connection string there, and then change the dbml file to reference that instead of
the web.config.
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 alt="Changes that were automatically applied to the project after I clicked OK" src="http://www.stuffthatjustworks.com/content/binary/New%20Settings%20File.png"&gt;
&lt;/p&gt;
&lt;p&gt;
This would probably be the behavior you would expect if the web.config was really
missing the connection string, but in my case the referenced connection string was
there and well-formed.&amp;nbsp; I know this, because the related code was&amp;nbsp;under
source control and other developers could&amp;nbsp;open the same&amp;nbsp;dbml file (from&amp;nbsp;the
shared code base)&amp;nbsp;and they&amp;nbsp;wouldn't get&amp;nbsp;the alert and everything worked
flawlessly.
&lt;/p&gt;
&lt;p&gt;
To me, it seemed like the LINQ to SQL designer on my machine was simply having trouble
reading from the configuration file ... so I thought it might be an issue with a particular
dll or registry entry.&amp;nbsp; Another thing that convinced me of this was the fact
that when you were in the dbml editor ... under the Connections property on my computer,
none of the connection strings from the web.config were included in the drop down
to select from.&amp;nbsp; But, when another developer would look at this on their machine
(using the same exact code base and files), their Visual Studio environment would
find those connection strings in the web.config and include them in the list to select
from.
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 alt="Connection Options on my computer containing no references to web.config connection strings" src="http://www.stuffthatjustworks.com/content/binary/What%20I%20See%20As%20Connection%20Options%20(Close%20Up).png"&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 alt="Connection Options on other computers containing references to web.config connection strings" src="http://www.stuffthatjustworks.com/content/binary/What%20Other%20Developers%20See%20As%20Connection%20Options%20(Close%20Up).png"&gt;
&lt;/p&gt;
&lt;p&gt;
I figured out that I could&amp;nbsp;just undo the changes to add the new file, and then
view the differences of the dbml file's XML and undo the reference change to make
it once again reference the web.config instead of the settings file it created ...
and that worked fine for a couple weeks, but eventually jumping through those extra
hoops that "should just work" got pretty&amp;nbsp;old.
&lt;/p&gt;
&lt;p&gt;
So I first tried to repair my Visual Studio install, but that didn't work.&amp;nbsp; Next,&amp;nbsp;I
completely uninstalled Visual Studio and then re-installed it and the related service
packs ... but that didn't work either.&amp;nbsp; I was about to just format my machine
and re-install Windows ... but I thought&amp;nbsp;I would give&amp;nbsp;Microsoft Support
a chance, hoping they could help me.&amp;nbsp; I knew this&amp;nbsp;was an obscure enough
problem that they probably wouldn't be much help, but I really hate paving my machine
... so it was worth a little time to give them a chance.&amp;nbsp; After explaining what
was going on to a technician, we tried to use ProcMon to figure out what was going
on behind the scenes.&amp;nbsp; We noticed several registry errors, and that further convinced
me that the problem was corrupted&amp;nbsp; or missing registry keys.&amp;nbsp; The support
technician said he would have to look into it more, but I&amp;nbsp;wasn't&amp;nbsp;going to
count on them as my only hope for a solution ... so I&amp;nbsp;kept investigating myself.&amp;nbsp; &lt;strong&gt;Apparently
when you uninstall Visual Studio, it doesn't remove all of the registry keys.&amp;nbsp;
It also doesn't overwrite them all when you run a repair.&lt;/strong&gt;&amp;nbsp; It doesn't
even remove them all when you remove all the other software that might have hooks
or add-ins related to Visual Studio.&amp;nbsp; So these corrupted or missing registry
keys could have persisted through the repair and re-install.
&lt;/p&gt;
&lt;p&gt;
Here are some of the issues we noticed in ProcMon (it is a snapshot of what was happening
when I would open the dbml file and the pop-up alert would appear, and then I would
click OK).&amp;nbsp; The one highlighted is the what I was guessing was the culprit, because
that missed registry key occurred right between the read of the dbml file and the
opening the related project (which I am guessing was to create the new settings file).&amp;nbsp;
You can ignore the "Fast IO Disallowed" stuff, because that is unrelated.
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 alt="Related errors from Process Monitor while opening the LINQ to SQL dbml file" src="http://www.stuffthatjustworks.com/content/binary/ProcMon%20Visual%20Studio%20DevEnv%20Registry%20Errors.png"&gt;
&lt;/p&gt;
&lt;p&gt;
So,&amp;nbsp;although the support technician had actually&amp;nbsp;explicitly advised me &lt;u&gt;not&lt;/u&gt; to
do this ... I decided to uninstall Visual Studio (and any other software add-ins that
might be related to it), manually delete the related registry keys contained in any
folder that appeared related to Visual Studio, and then do a&amp;nbsp;fresh install.&amp;nbsp; &lt;strong&gt;I
never think hacking in the registry is a good solution to a problem, but this was
my last ditch effort ... and I was resolved to do a full re-install of Windows if
it didn't work.&amp;nbsp; To my surprise ... &lt;u&gt;it actually worked&lt;/u&gt;.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I can't guarantee this will work for you, or even recommend it ... but here are the
registry folder locations I manually deleted:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;font face="Courier New"&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSCommon&lt;/font&gt; 
&lt;li&gt;
&lt;font face="Courier New"&gt;HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSTAHost&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Hopefully if you are still reading, this is the exact problem you are having and this
will work for you as well.&amp;nbsp; The only thing I can say is ... it worked on my machine,
and it saved me from having to completely re-install Windows to fix the problem.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=5d1e5dfa-ca14-4e9e-afff-c227e83b02d7" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=2ac9434a-78ca-4861-9168-72fcfad55055</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,2ac9434a-78ca-4861-9168-72fcfad55055.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We recently ran into a problem up at work where people were opening a particular spreadsheet
from a network fileshare, which had a lot of formulas that were tied to a few inputs. 
You would typically change one input cell, and a lot of the other related cells would
be recalculated and updated automatically.  However, a wierd issue started occuring
where some users would change the input and nothing would happen.  But ... when
they saved the worksheet, all of the related calculated cells would be updated at
that time.
</p>
        <p>
I think the issue was related to one person opening the spreadsheet on a Mac that
was running Office 2008, and when they saved it we noticed it changed a lot of subtle
things like the colors or formatting ... but I think it may have also changed the
formulas to be manually updated and only automatically updated when the file is saved,
which is an Excel Option.  Regardless of how this issue occurred ... here is
the fix:
</p>
        <ol>
          <li>
Open Excel, and click on the <img border="0" alt="Microsoft Office Button in Excel" src="http://www.stuffthatjustworks.com/content/binary/Office-Button.png" /> icon
in the top left of the window, then go to <strong>Excel Options</strong>.<br /><img border="0" alt="Open Excel Options dialog" src="http://www.stuffthatjustworks.com/content/binary/Open%20Excel%20Options.png" /><br /></li>
          <li>
Then go to the <strong>Formulas</strong> tab, and change the <strong>Calculation options</strong> to <strong>Automatic</strong>,
and hit <strong>OK </strong>to apply the changes.<br /><img border="0" alt="Change formula calculation options to automatic" src="http://www.stuffthatjustworks.com/content/binary/Change%20Formula%20Calculation%20Options%20To%20Automatic.png" /></li>
        </ol>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=2ac9434a-78ca-4861-9168-72fcfad55055" />
      </body>
      <title>How To: Fix Issue With Excel Not Automatically Updating Formula Calculations</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,2ac9434a-78ca-4861-9168-72fcfad55055.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToFixIssueWithExcelNotAutomaticallyUpdatingFormulaCalculations.aspx</link>
      <pubDate>Thu, 14 Jan 2010 16:32:59 GMT</pubDate>
      <description>&lt;p&gt;
We recently ran into a problem up at work where people were opening a particular spreadsheet
from a network fileshare, which had a lot of formulas that were tied to a few inputs.&amp;nbsp;
You would typically change one input cell, and a lot of the other related cells would
be recalculated and updated automatically.&amp;nbsp; However, a wierd issue started occuring
where some users would change the input and nothing would happen.&amp;nbsp; But ... when
they saved the worksheet, all of the related calculated cells would be updated at
that time.
&lt;/p&gt;
&lt;p&gt;
I think the issue was related to one person opening the spreadsheet on a Mac that
was running Office 2008, and when they saved it we noticed it changed a lot of subtle
things like the colors or formatting ... but I think it may have also changed the
formulas to be manually updated and only automatically updated when the file is saved,
which is an Excel Option.&amp;nbsp; Regardless of how this issue occurred ... here is
the fix:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Open Excel, and click on the&amp;nbsp;&lt;img border=0 alt="Microsoft Office Button in Excel" src="http://www.stuffthatjustworks.com/content/binary/Office-Button.png"&gt;&amp;nbsp;icon
in the top left of the window, then go to &lt;strong&gt;Excel Options&lt;/strong&gt;.&lt;br&gt;
&lt;img border=0 alt="Open Excel Options dialog" src="http://www.stuffthatjustworks.com/content/binary/Open%20Excel%20Options.png"&gt;
&lt;br&gt;
&lt;li&gt;
Then go to the &lt;strong&gt;Formulas&lt;/strong&gt; tab, and change the &lt;strong&gt;Calculation options&lt;/strong&gt; to &lt;strong&gt;Automatic&lt;/strong&gt;,
and hit &lt;strong&gt;OK &lt;/strong&gt;to apply the changes.&lt;br&gt;
&lt;img border=0 alt="Change formula calculation options to automatic" src="http://www.stuffthatjustworks.com/content/binary/Change%20Formula%20Calculation%20Options%20To%20Automatic.png"&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=2ac9434a-78ca-4861-9168-72fcfad55055" /&gt;</description>
      <category>How To</category>
      <category>Random</category>
    </item>
    <item>
      <trackback:ping>http://www.stuffthatjustworks.com/Trackback.aspx?guid=3e83b49a-eb4c-4321-a94a-692ec913dc52</trackback:ping>
      <pingback:server>http://www.stuffthatjustworks.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.stuffthatjustworks.com/PermaLink,guid,3e83b49a-eb4c-4321-a94a-692ec913dc52.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was recently using SQL Server Report Builder, and needed to format a date and time in
a specific way.  I went to edit the related expression, and looked for built-in
functions to help me work with dates under Common Functions &gt; Date &amp; Time ...
where I found FormatDateTime:
</p>
        <p>
          <img border="0" src="http://www.stuffthatjustworks.com/content/binary/Using%20FormatDateTime%20in%20SSRS%20Expression.png" alt="Using FormatDateTime in SSRS Expression" />
        </p>
        <p>
This is the example shown for how to use it:
</p>
        <p>
          <font face="Courier New">=FormatDateTime(Fields!BirthDate.Value, DateFormat.ShortDate)</font>
        </p>
        <p>
This is helpful, because the 2nd argument is obviously a DateFormat enumeration
... but what are the other members besides ShortDate?  I searched (like you might
have) and couldn't come up with anything.  The only thing I can assume, is that
the DateFormat enumeration used in SSRS expressions is the same as <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.dateformat.aspx" title="DateFormat enumeration">the
DateFormat enumeration in Visual Basic</a>, which is:
</p>
        <ul>
          <li>
GeneralDate 
</li>
          <li>
LongDate 
</li>
          <li>
ShortDate 
</li>
          <li>
LongTime 
</li>
          <li>
ShortTime</li>
        </ul>
        <p>
None of these "canned" formats matched the way I wanted to format the date, so I kept
looking and noticed some MSDN samples that used the <font face="Courier New">Format</font> method
instead of the <font face="Courier New">FormatDateTime</font> method.  In the
expression edittor, that function can be found under Common Functions &gt; Text:
</p>
        <p>
          <img border="0" src="http://www.stuffthatjustworks.com/content/binary/Format%20a%20date%20and%20time%20in%20SQL%20Report%20Builder%20Expressions.png" alt="Format a date and time in SQL Report Builder Expression" />
        </p>
        <p>
The Format method is very flexible, and allows you to use any of the standard string-based
format patterns you are probably already familar with.  Here are a few common
examples:
</p>
        <p>
          <font face="Courier New">=Format(Fields!myDateTime.Value, "M/d/yy") ... 6/15/09<br />
=Format(Fields!myDateTime.Value, "M/d/yyyy h:mmtt") ... 6/15/2009 2:45PM<br />
=Format(Fields!myDateTime.Value, "MM/dd/yy HH:mm") ... 06/15/09 14:45<br />
=Format(Fields!myDateTime.Value, "MMM d, yyyy") ... Jun 15, 2009<br /></font>
          <font face="Courier New">=Format(Fields!myDateTime.Value, "Short Date") ...
6/15/2009<br /><font face="Courier New">=Format(Fields!myDateTime.Value, "Long Date") ... Monday,
June 15, 2009</font></font>
        </p>
        <p>
Of course, the standard format strings like "Short Date" and "Long Date"  may
vary depending on the culture set on your system.  The examples above reflect
the "en-US" configuration.
</p>
        <p>
Then, here is a slight variation of the 2nd sample.  It is my personal
favorite and how I usually format all dates that have time values related to them,
because I think the lowercase AM/PM designator makes the value easier for someone
to scan, and requires less conscience effort to process.  If it is all uppercase,
the AM/PM designator seems to blend in with the rest of the text and you have to pay
a little closer attention to interpret the related value (even if it is just a tenth
of a second).
</p>
        <p>
          <font face="Courier New">=LCase(Format(Fields!myDateTime.Value, "M/d/yy h:mmtt"))
... 3/15/2009 2:45pm</font>
        </p>
        <img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=3e83b49a-eb4c-4321-a94a-692ec913dc52" />
      </body>
      <title>How To: Format Dates &amp; Times in SSRS Report Builder</title>
      <guid isPermaLink="false">http://www.stuffthatjustworks.com/PermaLink,guid,3e83b49a-eb4c-4321-a94a-692ec913dc52.aspx</guid>
      <link>http://www.StuffThatJustWorks.com/HowToFormatDatesTimesInSSRSReportBuilder.aspx</link>
      <pubDate>Tue, 29 Dec 2009 21:06:08 GMT</pubDate>
      <description>&lt;p&gt;
I was recently using SQL Server Report Builder, and needed to format a date and time&amp;nbsp;in
a specific way.&amp;nbsp; I went to edit the related&amp;nbsp;expression, and looked for built-in
functions to help me work with dates under Common Functions &amp;gt; Date &amp;amp; Time ...
where I found FormatDateTime:
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://www.stuffthatjustworks.com/content/binary/Using%20FormatDateTime%20in%20SSRS%20Expression.png" alt="Using FormatDateTime in SSRS Expression"&gt;
&lt;/p&gt;
&lt;p&gt;
This is the example shown for how to use it:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;=FormatDateTime(Fields!BirthDate.Value, DateFormat.ShortDate)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This is helpful, because the 2nd argument is obviously a&amp;nbsp;DateFormat enumeration
... but what are the other members besides ShortDate?&amp;nbsp; I searched (like you might
have) and couldn't come up with anything.&amp;nbsp; The only thing I can assume, is that
the DateFormat enumeration used in SSRS expressions is the same as &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.dateformat.aspx" title="DateFormat enumeration"&gt;the
DateFormat enumeration in Visual Basic&lt;/a&gt;, which is:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
GeneralDate 
&lt;li&gt;
LongDate 
&lt;li&gt;
ShortDate 
&lt;li&gt;
LongTime 
&lt;li&gt;
ShortTime&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
None of these "canned" formats matched the way I wanted to format the date, so I kept
looking and noticed some MSDN samples that used the &lt;font face="Courier New"&gt;Format&lt;/font&gt; method
instead of the &lt;font face="Courier New"&gt;FormatDateTime&lt;/font&gt; method.&amp;nbsp; In the
expression edittor, that function can be found under Common Functions &amp;gt; Text:
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://www.stuffthatjustworks.com/content/binary/Format%20a%20date%20and%20time%20in%20SQL%20Report%20Builder%20Expressions.png" alt="Format a date and time in SQL Report Builder Expression"&gt;
&lt;/p&gt;
&lt;p&gt;
The Format method is very flexible, and allows you to use any of the standard string-based
format patterns you are probably already familar with.&amp;nbsp; Here are a few common
examples:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;=Format(Fields!myDateTime.Value, "M/d/yy") ... 6/15/09&lt;br&gt;
=Format(Fields!myDateTime.Value, "M/d/yyyy h:mmtt") ... 6/15/2009 2:45PM&lt;br&gt;
=Format(Fields!myDateTime.Value, "MM/dd/yy HH:mm") ... 06/15/09 14:45&lt;br&gt;
=Format(Fields!myDateTime.Value, "MMM d, yyyy") ...&amp;nbsp;Jun 15, 2009&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;=Format(Fields!myDateTime.Value, "Short Date") ...
6/15/2009&lt;br&gt;
&lt;font face="Courier New"&gt;=Format(Fields!myDateTime.Value, "Long Date") ... Monday,
June 15, 2009&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Of course, the standard format strings like "Short Date" and "Long Date"&amp;nbsp; may
vary depending on the culture set on your system.&amp;nbsp; The examples above reflect
the&amp;nbsp;"en-US" configuration.
&lt;/p&gt;
&lt;p&gt;
Then, here is&amp;nbsp;a slight variation of the 2nd sample.&amp;nbsp; It is my&amp;nbsp;personal
favorite and how I usually format all dates that have time values related to them,
because I think the lowercase AM/PM designator makes the&amp;nbsp;value easier for someone
to scan, and requires less conscience effort to process.&amp;nbsp; If it is all uppercase,
the AM/PM designator seems to blend in with the rest of the text and you have to pay
a little closer attention to interpret the related value (even if it is just a tenth
of a second).
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;=LCase(Format(Fields!myDateTime.Value, "M/d/yy h:mmtt"))
... 3/15/2009 2:45pm&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.stuffthatjustworks.com/aggbug.ashx?id=3e83b49a-eb4c-4321-a94a-692ec913dc52" /&gt;</description>
      <category>Code</category>
      <category>How To</category>
    </item>
  </channel>
</rss>