<?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>Eric Fickes &#187; development</title>
	<atom:link href="http://ericfickes.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericfickes.com</link>
	<description>Internets, Databases, Skateboards, Ice Hockeys, and Family</description>
	<lastBuildDate>Thu, 22 Jul 2010 22:45:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>EMERGENT COLLECTIVE released, the community rejoices!</title>
		<link>http://ericfickes.com/2010/07/emergent-collective-one-released/</link>
		<comments>http://ericfickes.com/2010/07/emergent-collective-one-released/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 22:33:59 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[adobe]]></category>
		<category><![CDATA[band]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[denver]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[the compilers]]></category>
		<category><![CDATA[An Early Morning Letter - Displaced]]></category>
		<category><![CDATA[Bugbear]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[free cd]]></category>
		<category><![CDATA[James Allen]]></category>
		<category><![CDATA[Jazpicious]]></category>
		<category><![CDATA[Lee Fernandes]]></category>
		<category><![CDATA[musicians]]></category>
		<category><![CDATA[My Brother And I]]></category>
		<category><![CDATA[Partition 36]]></category>
		<category><![CDATA[Sea of Arrows]]></category>
		<category><![CDATA[Sean McCracken]]></category>
		<category><![CDATA[Sleepwalker]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1593</guid>
		<description><![CDATA[I&#8217;m happy to announce my band The Compilers have been included on the new EMERGENT COLLECTIVE ONE cd. This compilation is made up of developers in the Adobe community who are also involved with making music.  Go download it now, it&#8217;s free for all! A huge thanks goes out to creator of this compilation Joseph [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce my band <a href="http://compilersworld.com" target="_blank">The Compilers</a> have been included on the new <a title="Download the new EMERGENT COLLECTIVE compilation for free!" href="http://fracturedvisionmedia.com/FVM005/" target="_blank">EMERGENT COLLECTIVE ONE</a> cd.  This compilation is made up of developers in the Adobe community who are also involved with making music.  <a title="Download EMERGENT COLLECTIVE 1 for free" href="http://fracturedvisionmedia.com/FVM005/" target="_blank">Go download it now</a>, it&#8217;s free for all!</p>
<div id="attachment_1594" class="wp-caption aligncenter" style="width: 569px"><a href="http://fracturedvisionmedia.com/FVM005/" target="_blank"><img class="size-full wp-image-1594  " title="EMERGENT COLLECTIVE ONE compilation" src="http://ericfickes.com/wp-content/uploads/2010/07/EMERGENT_COLLECTIVE_ONE.png" alt="11 tracks from Adobe community members who also make music" width="559" height="639" /></a><p class="wp-caption-text">Download this free album now!</p></div>
<p>A huge thanks goes out to creator of this compilation <a title="Joseph Labrecque: Senior Multimedia Application Developer for the University of Denver and Owner of Fractured Vision Media, LLC. Joseph is an Adobe Higher Education Leader" href="http://inflagrantedelicto.memoryspiral.com/" target="_blank">Joseph Labrecque</a>.  Thank you for making this compilation and thank you for letting The Compilers submit our song &#8216;Sleep Tick v2&#8242;.  Be sure to read <a title="Joseph Labreqcue releases 'EMERGENT COLLECTIVE ONE' for free. The Adobe community rejoices!" href="http://inflagrantedelicto.memoryspiral.com/2010/07/emergent-collective-one-now-available/" target="_blank">Joseph&#8217;s comments about the compilation</a> he so graciously put out for all to enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/07/emergent-collective-one-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I am going to 360 Flex DC, and so should you</title>
		<link>http://ericfickes.com/2010/07/i-am-going-to-360-flex-dc-and-so-should-you/</link>
		<comments>http://ericfickes.com/2010/07/i-am-going-to-360-flex-dc-and-so-should-you/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 04:02:03 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[22nd Century]]></category>
		<category><![CDATA[360 Flex]]></category>
		<category><![CDATA[360 Flex DC 2010]]></category>
		<category><![CDATA[360flex]]></category>
		<category><![CDATA[360FlexAPalooza]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[DC]]></category>
		<category><![CDATA[Flex conference]]></category>
		<category><![CDATA[thecompilers]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1563</guid>
		<description><![CDATA[I&#8217;m happy to announce I received my Golden Ticket to speak at the next 360 Flex conference in Washington DC.  The conference will be held at the Hilton DC North Gaithersburg, September 19 &#8211; 22, 2010. I&#8217;m going to 360 Flex DC, and so should you I spoke at the last 360&#124;Flex in San Jose, but I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce I received my <a title="I got my 360 Flex golden ticket, just like Charlie got his chocolate factory ticket" href="http://en.wikipedia.org/wiki/Golden_Ticket" target="_blank">Golden Ticket</a> to speak at the next <a title="360 Flex is THE flex conference to attend" href="http://www.360flex.com" target="_blank">360 Flex</a> conference in Washington DC.  The conference will be held at the <a href="http://www1.hilton.com/en_US/hi/hotel/GAIGHHF-Hilton-Washington-DC-North-Gaithersburg-Maryland/index.do" target="_blank">Hilton DC North Gaithersburg</a>, September 19 &#8211; 22, 2010.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_1564" class="wp-caption aligncenter" style="width: 598px;"><a href="http://ericfickes.com/wp-content/uploads/2010/07/eric_golden_ticket.jpg" rel="lightbox[1563]"><span style="color: #000000;"><img class="size-full wp-image-1564" title="I got my golden ticket to 360 Flex DC 2010!" src="http://ericfickes.com/wp-content/uploads/2010/07/eric_golden_ticket.jpg" alt="I am speaking at 360 Flex DC" width="588" height="441" /></span></a>I&#8217;m going to 360 Flex DC, and so should you </dl>
</div>
<p>I spoke at the last <a title="I also spoke at 360 Flex San Jose" href="http://www.360flex.com/san-jose-2010/" target="_blank">360|Flex in San Jose</a>, but I&#8217;m already more excited for the DC conference, and here&#8217;s why.</p>
<ol>
<li>I&#8217;m speaking about the most exciting part of the Flash Platform, <a title="Adobe AIR2 release notes for developers" href="http://www.adobe.com/support/documentation/en/air/2/releasenotes_developers.html" target="_blank">AIR2</a></li>
<li><a title="Jesse Warden vs Jesse Freeman at 360 Flex DC - BE THERE!!!" href="http://www.360flex.com/blog/2010/07/360flex-jesse-vs-jesse/" target="_blank">Jesse vs. Jesse ( Flash vs Flex throwdown )</a></li>
<li>It&#8217;s in Washington DC</li>
<li>My band <a title="The Compilers World" href="http://compilersworld.com/" target="_blank">The Compilers</a> will be giving a lunch talk, as well as playing live at one of the parties</li>
<li>There is talk of <a title="Duane 'chaos' Nickull's band 22nd Century. Duane is a fellow bassist!" href="http://22ndcenturyofficial.com/" target="_blank">Duanne Nickull&#8217;s band 22nd Century</a> playing ( hopefully <a title="Sean the flex guy is my personal online DJ" href="http://twitter.com/seantheflexguy" target="_blank">Sean &#8216;the flex guy&#8217;</a> too )</li>
<li>Doug McCune is giving the opening Keynote speech on Monday</li>
<li>I get to hang out with the Flex community</li>
</ol>
<p>If you haven&#8217;t been to a 360 Flex conference yet I highly recommend it.  If you still need help deciding, here are a few conference questions for you.</p>
<ol>
<li>Do you currently work with or have any interest in <a title="Adobe Flex" href="http://www.adobe.com/products/flex/" target="_blank">Adobe Flex</a>?</li>
<li>Have you attended a 360 Flex conference yet?</li>
<li>Do you want to meet the community loudmouths you&#8217;re already following on Twitter?</li>
<li>Have you seen who is <a title="Speakers at 360|Flex DC 2010" href="http://www.360flex.com/speakers/" target="_blank">speaking at 360 Flex DC</a>?</li>
<li>Have you ever heard <a title="The Compilers world!" href="http://compilersworld.com/" target="_blank">The Compilers</a> play live?</li>
<li>Are you still reading this blog post?</li>
</ol>
<p>The last 360 Flex I spoke at was in San Jose and it rocked.  The city of San Jose bored me to tears, but I felt like I was living inside my twitter feed for three days.  My presentation was on the final day of 360 Flex, so I spent most of the conference preparing, and sitting in a few sessions here and there.  I spent almost half of my time in San Jose working and still met 10-15 of my twitter buddies, not to mention all the new contacts I met.  In a nutshell, if you attend a 360 Flex conference, you will meet the community.  In fact, you&#8217;d have to try pretty hard to not meet the Flex community.</p>
<p>If this sounds up your alley, go ahead and register to take advantage of the early adopter ticket price of $450.  I&#8217;m not sure when the ticket price will go up to $599, but I know it will so act fast.  If you make it to DC, be sure to find me and introduce yourself.  I promise it will be a good time.</p>
<table border="0" cellspacing="5" cellpadding="5" align="center">
<tbody>
<tr>
<th valign="top">
<p><div id="attachment_1578" class="wp-caption aligncenter" style="width: 160px"><a title="Register for 360|Flex DC now, and receive the early adopter rate $450" href="http://www.eventbrite.com/event/680816340/360flexhelpsell/872527234" target="_blank"><img class="size-full wp-image-1578 " title="360|Flex Washington DC 2010" src="http://ericfickes.com/wp-content/uploads/2010/07/site_badge_ef.png" alt="360|Flex Washington D.C. Sept.19-22 " width="150" height="158" /></a><p class="wp-caption-text">Early adopter price $450 </p></div></th>
<td valign="middle">
<h2>360|Flex Information</h2>
<h3><a href="http://www.360flex.com/" target="_blank">ABOUT</a></h3>
<h3><a href="http://360flex.com/downloads/schedule.pdf" target="_blank">SCHEDULE</a></h3>
<h3><a href="http://www.360flex.com/speakers/" target="_blank">SPEAKERS</a></h3>
<h3><a href="http://www.eventbrite.com/event/680816340/360flexhelpsell/872527234" target="_blank">REGISTER</a></h3>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/07/i-am-going-to-360-flex-dc-and-so-should-you/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DataBind a List of custom classes to an ASP:ListBox control</title>
		<link>http://ericfickes.com/2010/04/databind-a-list-of-custom-classes-to-an-asplistbox-control/</link>
		<comments>http://ericfickes.com/2010/04/databind-a-list-of-custom-classes-to-an-asplistbox-control/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 20:09:16 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[.NET framework]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[auto-implemented]]></category>
		<category><![CDATA[auto-implemented-properties]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[custom class]]></category>
		<category><![CDATA[DataBind]]></category>
		<category><![CDATA[DataSource]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[VO]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1415</guid>
		<description><![CDATA[Recently I was scratching my head at this error from the .NET Framework DataBinding: &#8216;MyApp.vo.customVO&#8217; does not contain a property with the name &#8216;Name&#8217; I was stumped because my custom VO class did in fact have a public property called Name.  After many trials and tribulations I figured out that .NET didn&#8217;t like how I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was scratching my head at this error from the .NET Framework</p>
<blockquote>
<h3><em><em>DataBinding: &#8216;MyApp.vo.customVO&#8217; does not contain a property with the name &#8216;Name&#8217;</em></em></h3>
</blockquote>
<p>I was stumped because my custom VO class did in fact have a public property called Name.  After many trials and tribulations I figured out that .NET didn&#8217;t like how I structured my custom class.</p>
<p>Here is what my original custom class looked like.</p>
<pre class="brush: csharp;">
namespace MyApp.vo
{
    public class customVO
    {
        public Int32 id  = 0;
        public DateTime time  = new DateTime();
        public string Name  = string.Empty;
        public string DeviceType  = string.Empty;
        public string ObjectIDs  = string.Empty;
    }
}
</pre>
<p>Luckily I have <a title="JetBrain's ReSharper is a must have for any .NET developer" href="http://www.jetbrains.com/resharper/" target="_blank">JetBrains ReSharper</a> installed, and it suggested using C#&#8217;s <a href="http://msdn.microsoft.com/en-us/library/bb384054.aspx" target="_blank">Auto-Implemented properties</a>.  This is the one thing I hadn&#8217;t thought about trying, and it ended up being the fix!  My new custom VO class now looks like this.</p>
<pre class="brush: csharp;">
namespace MyApp.vo
{
    public class customVO
    {
        public Int32 id { get; set; }
        public DateTime time { get; set; }
        public string DeviceType { get; set; }
        public string ObjectIDs { get; set; }
        public string Name { get; set; }
    }
}
</pre>
<p>So if you find yourself running into this error while trying to DataBind a collection of custom classes to a ListBox or similar control, have a look at your custom class and see if you can convert it over to using auto-implement properties as well.</p>
<p>Now I&#8217;m not suggesting this is the only way to DataBind a List of custom classes to a ListBox, but it solved my problem and let me do direct databinding from my service call without having to do any pre-processing on my list.</p>
<p>Hope this helps someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/04/databind-a-list-of-custom-classes-to-an-asplistbox-control/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Coldfusion and ASP.NET coexisting on IIS, where&#8217;d WebResource.axd go?</title>
		<link>http://ericfickes.com/2010/02/coldfusion-and-asp-net-coexisting-on-iis-whered-webresource-axd-go/</link>
		<comments>http://ericfickes.com/2010/02/coldfusion-and-asp-net-coexisting-on-iis-whered-webresource-axd-go/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 19:33:39 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[iis7]]></category>
		<category><![CDATA[inetmgr]]></category>
		<category><![CDATA[web.config]]></category>
		<category><![CDATA[webresource.axd]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1109</guid>
		<description><![CDATA[My Monday morning WTF comes from IIS7 on Windows 7.  I recently installed Coldfusion9 on this machine which has a handful of existing ASP.NET 3.5 web applications.  The problem I ran into came after installing Coldfusion9 and electing to configure all IIS websites to work with CF.  While that is convenient, it ended up breaking [...]]]></description>
			<content:encoded><![CDATA[<p>My Monday morning WTF comes from IIS7 on Windows 7.  I recently installed Coldfusion9 on this machine which has a handful of existing ASP.NET 3.5 web applications.  The problem I ran into came after installing Coldfusion9 and electing to configure all IIS websites to work with CF.  While that is convenient, it ended up breaking one of my ASP.NET applications that was using ASP Validation controls on a login form.  Now that things are figured out, here are the details.</p>
<p>Firing up my ASP.NET application gives me the error message :</p>
<p style="text-align: center;"><strong>The WebResource.axd handler must be registered in the configuration to process this request</strong></p>
<div id="attachment_1110" class="wp-caption aligncenter" style="width: 310px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/axd-handler-error.png" rel="lightbox[1109]"><img class="size-medium wp-image-1110" title="WebResource.axd handler must be registered" src="http://ericfickes.com/wp-content/uploads/2010/02/axd-handler-error-300x177.png" alt="Misleading web handler error message" width="300" height="177" /></a><p class="wp-caption-text">WebResource.axd handler must be registered</p></div>
<p>Obviously all I could think is WTF?!?!? since this application worked on Friday and now it is broken.  The first thing I want to point out is that in my situation, the suggested solution of mapping WebResource.axd in the httpHandlers section of my web.config did <em><strong>not</strong></em> help this problem.  After some googling I cam across <a title="Problems with ASP.NET 2.0 Applications with Validation Controls" href="http://forums.iis.net/p/1147595/1861983.aspx#1861983" target="_blank">this post on the IIS.NET forums</a> which put me on the right track.  You can read the details there if you want a good background on MS&#8217; response and other users running CF and ASP.NET on the same box.</p>
<p>I&#8217;m happy to say I have three workarounds for this issue.  Hopefully these will help you as well.</p>
<h3>1. Change your AppPool to run in Classic Mode</h3>
<ol>
<li>In inetmgr, put your web application into it&#8217;s own Application Pool ( unless it&#8217;s already in it&#8217;s own pool )</li>
<li>Change that AppPool&#8217;s Managed pipeline mode to &#8220;Classic&#8221;</li>
<li>You should be good to go</li>
</ol>
<div id="attachment_1111" class="wp-caption aligncenter" style="width: 310px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/change-apppool-2-classic.png" rel="lightbox[1109]"><img class="size-medium wp-image-1111" title="Edit Application Pool &gt; Managed Pipeline Mode" src="http://ericfickes.com/wp-content/uploads/2010/02/change-apppool-2-classic-300x266.png" alt="Change Managed Pipeline Mode to Classic" width="300" height="266" /></a><p class="wp-caption-text">Classic mode is for compatibility ( think IIS6 )</p></div>
<h3>2. Stop using ASP Validation controls</h3>
<p>All ASP.NET Validation controls are hosted by WebResource.axd.  If you stop using ASP Validator controls, the server will stop asking for WebResource.axd.</p>
<div id="attachment_1112" class="wp-caption aligncenter" style="width: 301px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/stop-using-validators.png" rel="lightbox[1109]"><img class="size-medium wp-image-1112" title="Don't use ASP Validator controls" src="http://ericfickes.com/wp-content/uploads/2010/02/stop-using-validators-291x300.png" alt="Comment out ASP Validator controls" width="291" height="300" /></a><p class="wp-caption-text">Removing ASP Validator controls should remove this error</p></div>
<h3>3. Remove Coldfusion handler mappings from your ASP.NET site</h3>
<p>If your ASP.NET app isn&#8217;t using Coldfusion, I would suggest doing this as your solution.  Even if you do need Coldfusion in your ASP.NET app, you could still host your CF app in it&#8217;s own Virtual Directory and request if via ASP.NET.</p>
<ol>
<li>Open inetmgr</li>
<li>Select your web app on the left ( under Default Web Site )</li>
<li>In Features View on the right, double click Handler Mappings</li>
<li>Sort your Handler Mappings by Name, and remove all entries titled &#8220;AboMapperCustom-*&#8221;</li>
<li>Now your ASP.NET should work like a champ.</li>
</ol>
<div id="attachment_1113" class="wp-caption aligncenter" style="width: 310px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/inetmgr-handlerMappings.png" rel="lightbox[1109]"><img class="size-medium wp-image-1113" title="inetmgr Handler Mappings" src="http://ericfickes.com/wp-content/uploads/2010/02/inetmgr-handlerMappings-300x238.png" alt="IIS7 inetmgr Handler Mappings" width="300" height="238" /></a><p class="wp-caption-text">IIS7 Handler Mappings</p></div>
<div id="attachment_1114" class="wp-caption aligncenter" style="width: 310px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/remove-cf-mappings.png" rel="lightbox[1109]"><img class="size-medium wp-image-1114" title="Coldfusion9 Handler Mappings" src="http://ericfickes.com/wp-content/uploads/2010/02/remove-cf-mappings-300x242.png" alt="Coldfusion9 Handler Mappings" width="300" height="242" /></a><p class="wp-caption-text">Coldfusion9 Handler Mappings</p></div>
<p>Monday WTF solved.  Now to get back to pushing buttons.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/02/coldfusion-and-asp-net-coexisting-on-iis-whered-webresource-axd-go/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What happens in EXEC, stays in EXEC. Lifespan of a MSSQL table variable</title>
		<link>http://ericfickes.com/2010/02/using-mssql-table-variables-with-exec-statements/</link>
		<comments>http://ericfickes.com/2010/02/using-mssql-table-variables-with-exec-statements/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 19:44:49 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[tsql]]></category>
		<category><![CDATA[exec]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mssql2000]]></category>
		<category><![CDATA[mssql2005]]></category>
		<category><![CDATA[scope]]></category>
		<category><![CDATA[SELECT INTO]]></category>
		<category><![CDATA[table variable]]></category>
		<category><![CDATA[temp table]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1080</guid>
		<description><![CDATA[One of my all time favorite features of MSSQL 2005+ is being able to create table variables on the fly from SELECT statements. This isn&#8217;t a lesson in what table variables are, but here is an easy sample in case this is a new concept. Running this query SELECT * INTO #myTableVar FROM YourTable Gives [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">One of my all time favorite features of MSSQL 2005+ is being able to create table variables on the fly from SELECT statements.  This isn&#8217;t a lesson in what table variables are, but here is an easy sample in case this is a new concept.</p>
<p style="text-align: left;">Running this query</p>
<pre class="brush: sql;">SELECT * INTO #myTableVar FROM YourTable</pre>
<p>Gives you a new table variable named myTableVar.  Table variables are scoped to the active connection, so running this will work.</p>
<pre class="brush: sql;">
// make table var
SELECT * INTO #myTableVar FROM YourTable
// show me the data
SELECT * FROM #myTableVar
// you can drop it if you wish
DROP TABLE #myTableVar
</pre>
<p>However, let&#8217;s say you have an aspx page or a sproc that runs this query.</p>
<pre class="brush: sql;">SELECT * INTO #myTableVar FROM YourTable</pre>
<p>You can not access myTableVar in a separate connection to the database because as soon as the first query&#8217;s connection closes, myTableVar gets dropped.     Here are a few other scenarios that also demonstrate the scoping of a table variable.</p>
<pre class="brush: sql;">
-- FAILS
EXEC ('SELECT * INTO #tmp FROM MyTable;');
-- #tmp does not exist
SELECT * FROM #tmp
</pre>
<div id="attachment_1084" class="wp-caption aligncenter" style="width: 404px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/exec1-no-tmp-table.png" rel="lightbox[1080]"><img class="size-full wp-image-1084      " title="Table variable lives inside of EXEC" src="http://ericfickes.com/wp-content/uploads/2010/02/exec1-no-tmp-table.png" alt="#tmp only exists inside of EXEC" width="394" height="179" /></a><p class="wp-caption-text">Table variable #tmp lives inside of EXEC</p></div>
<p>Here we see that the table variable #tmp only lives for the life of the statement inside of EXEC.  The second SELECT * calls is outside of the EXEC statement.</p>
<pre class="brush: sql;">
-- #tmp2 works inside of EXEC statement
EXEC ('SELECT * INTO #tmp2 FROM MyTable; SELECT * FROM #tmp2');
</pre>
<div id="attachment_1086" class="wp-caption aligncenter" style="width: 570px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/exec2-tmp-inside-exec.png" rel="lightbox[1080]"><img class="size-full wp-image-1086   " title="tmp2 lives inside of EXEC" src="http://ericfickes.com/wp-content/uploads/2010/02/exec2-tmp-inside-exec.png" alt="table variables in EXEC live in EXEC" width="560" height="111" /></a><p class="wp-caption-text">What happens in EXEC, stays in EXEC</p></div>
<p>Here #tmp2 works because it&#8217;s being used inside of the EXEC statement.  This is worth knowing if you work with dynamic sql statements and exec.</p>
<pre class="brush: sql;">
-- works!
SELECT * INTO #tmp FROM MyTable;
-- #tmp exists
SELECT * FROM #tmp
</pre>
<div id="attachment_1087" class="wp-caption aligncenter" style="width: 318px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/exec3-normal-tmp-exists.png" rel="lightbox[1080]"><img class="size-full wp-image-1087" title="typical sample of using mssql table variable" src="http://ericfickes.com/wp-content/uploads/2010/02/exec3-normal-tmp-exists.png" alt="typical sample of using mssql table variable" width="308" height="153" /></a><p class="wp-caption-text">typical sample of using mssql table variable</p></div>
<p>This is a typical example that you may use inside a sproc, trigger, script, etc.  Both sql calls live in the same space, so #tmp exists.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/02/using-mssql-table-variables-with-exec-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to JOIN two tables using LINQ to SQL</title>
		<link>http://ericfickes.com/2010/02/how-to-join-two-tables-using-linq-to-sql/</link>
		<comments>http://ericfickes.com/2010/02/how-to-join-two-tables-using-linq-to-sql/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 01:27:53 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[linq to sql]]></category>
		<category><![CDATA[linqtosql]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1065</guid>
		<description><![CDATA[Wanted to share this since it gave me so much trouble figuring out.  It&#8217;s a simple SQL query ported to LINQ to SQL that joins two tables to return a filtered listed of data. Here are the tables from my schema Here is a basic SQL statement I could fire to retrieve my user videos. [...]]]></description>
			<content:encoded><![CDATA[<p>Wanted to share this since it gave me so much trouble figuring out.  It&#8217;s a simple SQL query ported to LINQ to SQL that joins two tables to return a filtered listed of data.</p>
<p>Here are the tables from my schema<br />
<a href="http://ericfickes.com/wp-content/uploads/2010/02/user-user_videos-video.png" rel="lightbox[1065]"><img class="aligncenter size-full wp-image-1068" title="My three user tables" src="http://ericfickes.com/wp-content/uploads/2010/02/user-user_videos-video.png" alt="user, user_video, video tables" width="465" height="317" /></a></p>
<p>Here is a basic SQL statement I could fire to retrieve my user videos.</p>
<pre class="brush: sql;">
select  *
from    video v, user_videos uv
where   v.vid = uv.vid
and     uv.uid = 2
</pre>
<p><a href="http://ericfickes.com/wp-content/uploads/2010/02/uservideos-SQL.png" rel="lightbox[1065]"><img class="aligncenter size-full wp-image-1069" title="Data returned from this SQL statement" src="http://ericfickes.com/wp-content/uploads/2010/02/uservideos-SQL.png" alt="User 2 has two videos" width="499" height="220" /></a><br />
Here is how you would run the same query using .net&#8217;s LINQ to SQL.</p>
<pre class="brush: csharp;">
// create DB connection
var db = new DBCONN();
// run query
List&lt;video&gt; uvids = (
    from c in db.video
    join o in db.user_videos
    on c.vid equals o.vid
    where o.uid == 2
    select c
).ToList();
</pre>
<p>This query differs slightly from the screenshot below because I used it in a WCF Service.</p>
<p><a href="http://ericfickes.com/wp-content/uploads/2010/02/uservideos-LINQTOSQL.png" rel="lightbox[1065]"><img class="aligncenter size-full wp-image-1070" title="Same query run via LINQ to SQL" src="http://ericfickes.com/wp-content/uploads/2010/02/uservideos-LINQTOSQL.png" alt="Same data, different retrieval method" width="488" height="419" /></a></p>
<p>The variable DBCONN is my database connection that I established when mapping my DB.  If you are not familiar with how to set this up, use the Visual Studio&#8217;s &#8220;Add the ADO.NET Entity Data Model&#8221; wizard.  With your .net project open, right click your project, left click on &#8220;Add the ADO.NET Entity Data Model&#8221;.  This wizard will walk you through setting up everything you need to setup your DB model file ( edmx ), as well as setting up your database connection and saving it in web.config.</p>
<p>Jesse Liberty did a <a title="ADO.NET DataEntities and WCF Feeding a Silverlight DataGrid" href="http://silverlight.net/learn/tutorials/adonetdataentities-cs/" target="_blank">simple tutorial that uses this wizard in a WCF service application</a>.</p>
<p>I hope this helps somebody out.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/02/how-to-join-two-tables-using-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Come have a 360Flex chat with me and Jun Heider</title>
		<link>http://ericfickes.com/2010/02/come-have-a-360flex-chat-when-me-and-jun-heider/</link>
		<comments>http://ericfickes.com/2010/02/come-have-a-360flex-chat-when-me-and-jun-heider/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 23:16:52 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexbuilder]]></category>
		<category><![CDATA[360flex]]></category>
		<category><![CDATA[adobeconnect]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[jun heider]]></category>
		<category><![CDATA[speaker]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1060</guid>
		<description><![CDATA[Chat is @ Thursday Feb 11th, 11:30am MST Jun Heider and myself will be talking to the 360&#124;Flex guys tomorrow about our session.  It’s actually going to be a back-to-back mega session comparing the latest and greatest on both the Flash Platform and the Silverlight Platform. Come check it out and feel free to ask [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Chat is @ Thursday Feb 11th, 11:30am MST</strong></p>
<p><a href="http://www.iheartair.com/" target="_blank">Jun Heider</a> and myself will be talking to the 360|Flex guys tomorrow about our session.  It’s actually going to be a back-to-back mega session comparing the latest and greatest on both the Flash Platform and the Silverlight Platform.</p>
<p>Come check it out and feel free to ask questions…although for the good stuff you’ll have to wait until our talks. <img src="http://www.iheartair.com/wp-includes/images/smilies/icon_wink.gif" alt=";-)" /></p>
<p>Here’s the full details: <a href="http://www.360flex.com/blog/2010/02/360flex-speaker-chat-eric-fickes-and-jun-heider/">http://www.360flex.com/blog/2010/02/360flex-speaker-chat-eric-fickes-and-jun-heider/</a></p>
<p>I hope to see you online tomorrow or at 360 Flex in March.</p>
<div class="wp-caption aligncenter" style="width: 110px"><br />
<a href="http://360flex-ericf.eventbrite.com/" target="_blank"><br />
<img title="I'm speaking at 360 Flex 2010" src="http://ericfickes.com/code/badge-2.png" alt="I'm speaking at 360 Flex 2010" width="100" height="100" /></a><p class="wp-caption-text">I&#39;m speaking at 360 Flex 2010</p></div>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/02/come-have-a-360flex-chat-when-me-and-jun-heider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invalid token &#8216;void&#8217; in class, struct, or interface member declaration</title>
		<link>http://ericfickes.com/2010/02/invalid-token-void-in-class-struct-or-interface-member-declaration/</link>
		<comments>http://ericfickes.com/2010/02/invalid-token-void-in-class-struct-or-interface-member-declaration/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 23:32:34 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[ADO.NET Entity Data Model]]></category>
		<category><![CDATA[edmx]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[visual studio 2008]]></category>
		<category><![CDATA[void]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1041</guid>
		<description><![CDATA[EDIT : After finishing this post I ran into all sorts of other strange issues and restarted using a Web Appliction instead of a plain old Website.  Between IntelliSense not showing any classes, to project reference issues, I couldn&#8217;t figured it out in time.  I&#8217;m sure there&#8217;s a way, I just had to move on.  So [...]]]></description>
			<content:encoded><![CDATA[<h2>EDIT :</h2>
<p>After finishing this post I ran into all sorts of other strange issues and restarted using a Web Appliction instead of a plain old Website.  Between <a title="IntelliSense is the BEST feature of all Visual Studios" href="http://en.wikipedia.org/wiki/IntelliSense" target="_blank">IntelliSense</a> not showing any classes, to project reference issues, I couldn&#8217;t figured it out in time.  I&#8217;m sure there&#8217;s a way, I just had to move on.  So maybe this ramble below will be helpful for someone.</p>
<address>EF</address>
<p>Just ran into something quirky with Visual Studio 2008&#8242;s new ADO.NET Entity Data Model wizard.  While working on an ASP.NET 3.5 website ( not a codebehind web application ) I was trying to get the ADO.NET Entity Data model wizard to work with MySQL and ran into a probable Visual Studio bug.  To sum up the issue, if you are going to add a new edmx to your project, do NOT save it to the App_Code folder initially.  Put it in your root folder, compile your project, then move the edmx where you&#8217;d like.</p>
<p>Assuming you&#8217;ve already created your ASP.NET Website project, here&#8217;s how you reproduce this issue.</p>
<h3 style="text-align: center;"><strong>Right click your project and left click &#8216;Add New Item&#8217;</strong></h3>
<p style="text-align: center;">
<div id="attachment_1042" class="wp-caption aligncenter" style="width: 390px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/vs1-AddNewItem.png" rel="lightbox[1041]"><img class="size-full wp-image-1042" title="Add New Item" src="http://ericfickes.com/wp-content/uploads/2010/02/vs1-AddNewItem.png" alt="Right click your project, left click Add New Item" width="380" height="225" /></a><p class="wp-caption-text">Add New Item</p></div>
<h3 style="text-align: center;"><strong>Select ADO.NET Entity Data Model, name it, select your language of preference</strong></h3>
<p style="text-align: center;">
<div id="attachment_1045" class="wp-caption aligncenter" style="width: 372px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/vs2-NewEDM1.png" rel="lightbox[1041]"><img class="size-full wp-image-1045" title="New ADO.NET Entity Data Model" src="http://ericfickes.com/wp-content/uploads/2010/02/vs2-NewEDM1.png" alt="New ADO.NET Entity Data Model" width="362" height="466" /></a><p class="wp-caption-text">ADO.NET Entity Data Model</p></div>
<h3 style="text-align: center;"><strong>Click Yes to the &#8216;Store in App_Code&#8217; prompt</strong></h3>
<p style="text-align: center;"><strong> </strong></p>
<div id="attachment_1046" class="wp-caption aligncenter" style="width: 500px"><strong><strong><a href="http://ericfickes.com/wp-content/uploads/2010/02/vs3-AddToAPP_CODE.png" rel="lightbox[1041]"><img class="size-full wp-image-1046" title="Place your edmx in App_Code folder" src="http://ericfickes.com/wp-content/uploads/2010/02/vs3-AddToAPP_CODE.png" alt="Place your edmx in App_Code folder" width="490" height="199" /></a></strong></strong><p class="wp-caption-text">Place file in &#39;App_Code&#39; folder</p></div>
<p><strong> </strong></p>
<h3 style="text-align: center;"><strong>Complete the new Entity Data Model wizard</strong></h3>
<p style="text-align: center;"><a title="ADO.NET DataEntities and WCF Feeding a Silverlight DataGrid" href="http://silverlight.net/learn/tutorials/adonetdataentities-cs/" target="_blank">See this tutorial if you have not done this before</a></p>
<p style="text-align: center;">
<p style="text-align: center;">
<h3 style="text-align: center;"><strong>Compile project after completing wizard</strong></h3>
<p style="text-align: left;">
<div id="attachment_1047" class="wp-caption aligncenter" style="width: 665px"><a href="http://ericfickes.com/wp-content/uploads/2010/02/vs4-BuildFail.png" rel="lightbox[1041]"><img class="size-full wp-image-1047" title="Invalid token 'void' in class, struct, or interface member declaration" src="http://ericfickes.com/wp-content/uploads/2010/02/vs4-BuildFail.png" alt="Invalid token 'void' in class, struct, or interface member declaration" width="655" height="399" /></a><p class="wp-caption-text">Invalid token &#39;void&#39; in class, struct, or interface member declaration</p></div>
<p style="text-align: left;">At this point your project should have a new.edmx file located inside of the App_Code folder, but the project won&#8217;t build without failing.  If you are stuck in this predicament, follow this workaround.</p>
<h3 style="text-align: center;"><strong>Move .edmx to root folder and rebuild</strong></h3>
<p style="text-align: left;"><strong> </strong></p>
<div id="attachment_1048" class="wp-caption aligncenter" style="width: 346px"><strong><strong><a href="http://ericfickes.com/wp-content/uploads/2010/02/vs5-move_edmx.png" rel="lightbox[1041]"><img class="size-full wp-image-1048" title="Move edmx to root and recompile, no errors!" src="http://ericfickes.com/wp-content/uploads/2010/02/vs5-move_edmx.png" alt="Move edmx to root and recompile, no errors!" width="336" height="468" /></a></strong></strong><p class="wp-caption-text">WORKAROUND : move edmx to root folder, then recompile</p></div>
<p><strong> </strong></p>
<p style="text-align: left;">
<p style="text-align: left;">After moving your edmx file to the root folder you should be able to compile without problem.  Assuming this solves your problem, you should be able to move your edmx file to the App_Code folder without problem.  Seems like an initial compile problem<strong>.<br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/02/invalid-token-void-in-class-struct-or-interface-member-declaration/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Select random value from a range of values</title>
		<link>http://ericfickes.com/2010/01/select-random-value-from-a-range-of-values/</link>
		<comments>http://ericfickes.com/2010/01/select-random-value-from-a-range-of-values/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 01:08:52 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[tsql]]></category>
		<category><![CDATA[#table]]></category>
		<category><![CDATA[cte]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mssql2000]]></category>
		<category><![CDATA[mssql2005]]></category>
		<category><![CDATA[table variable]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=1020</guid>
		<description><![CDATA[Earlier I blogged about creating random numbers using tsql functions.  Here are two techniques for selecting a random value from a pre-defined range of values in a tsql script.  The first technique uses a table variable ( MSSQL 2000 + ), and the second uses a Common Table Expression or CTE ( MSSQL 2005+ ). [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier I blogged about <a title="TSQL UDFs for generating random numbers" href="http://ericfickes.com/2009/09/generate-random-integers-using-tsql-udfs/" target="_blank">creating random numbers using tsql functions</a>.  Here are two techniques for selecting a random value from a pre-defined range of values in a tsql script.  The first technique uses a <a title="MSSQL 2000 let's you create table variables" href="http://msdn.microsoft.com/en-us/library/aa260638%28SQL.80%29.aspx" target="_blank">table variable</a> ( MSSQL 2000 + ), and the second uses a <a title="CTEs in MSSQL 2005 let you build queries a little differently" href="http://technet.microsoft.com/en-us/library/ms175972%28SQL.90%29.aspx" target="_blank">Common Table Expression</a> or CTE ( MSSQL 2005+ ).</p>
<h3>Select a random value using a table variable</h3>
<pre class="brush: sql;">

-- var to hold random integer
declare @field_val int

-- create table var to hold value range [ 0, 512, 1024, 2048, 4096 ]
-- inserting the first value sets the structure for the table variable
SELECT 0 AS 'num'
INTO #temp

-- insert data into table var
INSERT INTO #temp VALUES ( 512 )
INSERT INTO #temp VALUES ( 1024 )
INSERT INTO #temp VALUES ( 2048 )
INSERT INTO #temp VALUES ( 4096 )

-- assign random value
SELECT TOP 1 @field_val = num FROM #temp ORDER BY NEWID()

-- show value
SELECT @field_val

-- drop the table variable
DROP TABLE #temp
</pre>
<h3>Select a random value using a CTE</h3>
<pre class="brush: sql;">
-- define our data table
WITH data( car )
AS
(
	-- UNION together our range of values
	SELECT 'audi' AS 'car'
	UNION
	SELECT 'bmw' AS 'car'
	UNION
	SELECT 'infinity' AS 'car'
	UNION
	SELECT 'lexus' AS 'car'
	UNION
	SELECT 'porsche' AS 'car'
)
-- select a random value
SELECT TOP 1 car FROM data
ORDER BY NEWID()
</pre>
<p>Both of these techniques can be used with numbers or text.  Just be sure to mind your quotes, and variable datatypes.  Being able to pick a random value in data generation scripts has proven very useful.  I hope this helps somebody else out as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2010/01/select-random-value-from-a-range-of-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I wonder if using Coldfusion9&#8242;s ORM would make this easier?</title>
		<link>http://ericfickes.com/2009/12/i-wonder-if-using-coldfusion9s-orm-would-make-this-easier/</link>
		<comments>http://ericfickes.com/2009/12/i-wonder-if-using-coldfusion9s-orm-would-make-this-easier/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 02:50:09 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[adobe]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[coldfusion9]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=979</guid>
		<description><![CDATA[Rolling my own SQL solution Recently I was working on a medical website and was tasked with building a doctor directory page that had to pull data from three related tables.  For the viewers at home, here is a simplified view of my tables. The first version of the page was easy to whip up [...]]]></description>
			<content:encoded><![CDATA[<h2>Rolling my own SQL solution</h2>
<p>Recently I was working on a medical website and was tasked with building a <a href="http://sgpn.org/physicians.cfm" target="_blank">doctor directory page</a> that had to pull data from three related tables.  For the viewers at home, here is a simplified view of my tables.</p>
<div id="attachment_981" class="wp-caption aligncenter" style="width: 361px"><a href="http://ericfickes.com/wp-content/uploads/2009/12/doctor-practice-locations.png" rel="lightbox[979]"><img class="size-full wp-image-981" title="doctor-practice-locations" src="http://ericfickes.com/wp-content/uploads/2009/12/doctor-practice-locations.png" alt="Database tables : Doctors, Practices, and Locations" width="351" height="296" /></a><p class="wp-caption-text">Doctors, Practices, and Locations oh my</p></div>
<p>The first version of the page was easy to whip up because we were only showing primary location address which lives in the practices table.  ( NOTE : The diagram above was dumbed down to support this post ).  When the request came in to show all locations for each doctor&#8217;s practice, that&#8217;s when I had to put on my wizard hat and get tricky.</p>
<p>After some thinking I came up with two options for adding all locations for each doctor row :</p>
<ol>
<li>Build a second locations query for each doctor in the first query, then use code to merge the data together</li>
<li>Update the first query to include all necessary data, then use code to merge the data into a loopable structure</li>
</ol>
<p>Being a SQL junky, I decided to take the second route so I&#8217;m still only hitting the database once.  In the first version of this page, we always had one row per doctor and didn&#8217;t have to do any post processing of the data prior to sending to the page.  However, when the locations table gets added to our sql query, all of the doctor data gets duplicated for each location they are associated with, making the dataset look like this.</p>
<div id="attachment_984" class="wp-caption aligncenter" style="width: 474px"><a href="http://ericfickes.com/wp-content/uploads/2009/12/doctor-query.png" rel="lightbox[979]"><img class="size-full wp-image-984" title="doctor-query" src="http://ericfickes.com/wp-content/uploads/2009/12/doctor-query.png" alt="doctors, practice, and locations all in a single query" width="464" height="216" /></a><p class="wp-caption-text">When joining the third table, the first two get duplicated</p></div>
<p>Now that we&#8217;ve got all the data, you&#8217;ll notice that the doctor information gets duplicated.  This is where I built a cffunction to convert this query into a structure of individual doctors, each having an array of locations.  I used the doctor&#8217;s full name and id as the structure keys.  Great, now I can just loop through my new structure of doctors, then loop through each doctor.location array to draw the updated html table.  That is the goal here, but we&#8217;re not ready just yet.</p>
<p>If you&#8217;ve ever tried to <a title="cfloop: looping over a COM collection or structure" href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-71a6.html" target="_blank">loop over a Structure in Coldfusion</a>, you&#8217;ve probably noticed controlling the order of your data coming back can be tricky.  Here&#8217;s an example of what I&#8217;m talking about when looping through a structure.</p>
<div id="attachment_987" class="wp-caption aligncenter" style="width: 383px"><a href="http://ericfickes.com/wp-content/uploads/2009/12/simple-struct-loop.png" rel="lightbox[979]"><img class="size-full wp-image-987" title="simple-struct-loop" src="http://ericfickes.com/wp-content/uploads/2009/12/simple-struct-loop.png" alt="Looping through CF Structures, doesn't always loop in the order you'd expect" width="373" height="184" /></a><p class="wp-caption-text">Looping through a coldfusion structure can be a challenge</p></div>
<p>To get around this random order of looping through a structure, I did two steps prior to building the updated html table.</p>
<pre class="brush: coldfusion;">
	// UPDATE : extract key list ( DR full names ) so
	// you can sort the physicians my last name
	dr_list = StructKeyList( providers_struct );
	dr_list = ListSort( dr_list, &quot;textnocase&quot; );
</pre>
<p>This gives me an alphabetized list of all doctors inside my structure, which I convert to an array then loop through.  I know have a sorted loop that can pick all necessary doctor data out of my structure on command.  This solution took a little bit of time to figure, but wasn&#8217;t too bad.  After thinking about all the work needed to make this update, I wondered if using Coldfusion9&#8242;s Hibernate ORM would have made this update any easier.</p>
<h2>Porting SQL to ORM</h2>
<p>The first step in setting up  <a title="ColdFusion 9 has Hibernate built right in!" href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSD628ADC4-A5F7-4079-99E0-FD725BE9B4BD.html" target="_blank">Coldfusion9&#8242;s ORM</a> for this code is to enable the ORM in the application.</p>
<p>At the top of my Application.cfc I added the following lines.</p>
<pre class="brush: coldfusion;">
	&lt;cfscript&gt;
		// enable ORM
		this.ormenabled = true;

		// my datasource name, setup in the CFAdmin
		this.datasource = &quot;mysql-test&quot;;

		// the folder in my app where the cfc mapping files are location
		this.ormsettings.cfclocation = &quot;mappings&quot;;

		// this wasn't setup automatically for me
		this.ormsettings.dialect = &quot;MySQL&quot;;
	&lt;/cfscript&gt;
</pre>
<p>If you haven&#8217;t setup ORM in your Coldfusion9 application before, be sure to bookmark <a title="How do I configure ORM in Coldfusion9" href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html" target="_blank">this livedoc page on configuring ORM</a>.  It will give you all the lowdown on all the fancy ORM bells and whistles.</p>
<p>After ORM is enabled, it was time to create my Hibernate mapping files for each of the database tables involved in this code.  For convenience sake, I went the CFC route, and only mapped the columns required for this example.  There are a number of ways to <a title="Define ORM mapping in Coldfusion9" href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS53C28604-E798-4175-97AE-D7BDF124056C.html" target="_blank">define ORM mappings, refer to this livedocs page to find out more.</a> Here are my three hibernate mapping cfcs.</p>
<p><strong>doctor.cfc</strong></p>
<pre class="brush: coldfusion;">
&lt;cfcomponent persistent=&quot;true&quot; entityname=&quot;Doctor&quot; table=&quot;providers&quot;&gt;
    &lt;cfproperty name=&quot;id&quot; column=&quot;provider_id&quot; generator=&quot;increment&quot;&gt;

    &lt;!--- one to many relationship Doctor.practice = Practice ---&gt;
    &lt;cfproperty name=&quot;practice&quot; fieldtype=&quot;one-to-one&quot; cfc=&quot;PRACTICE&quot; fkcolumn=&quot;practice_id&quot;&gt;

    &lt;cfproperty name=&quot;PracticeId&quot; column=&quot;practice_id&quot; insert=&quot;false&quot; update=&quot;false&quot;&gt;

    &lt;cfproperty name=&quot;FirstName&quot; column=&quot;first_name&quot;&gt;
    &lt;cfproperty name=&quot;LastName&quot; column=&quot;last_name&quot;&gt;
    &lt;cfproperty name=&quot;status&quot; column=&quot;status&quot;&gt;
    &lt;cfproperty name=&quot;is_midlevel&quot; column=&quot;is_midlevel&quot;&gt;
&lt;/cfcomponent&gt;
</pre>
<p><strong>practice.cfc</strong></p>
<pre class="brush: coldfusion;">
&lt;cfcomponent persistent=&quot;true&quot; entityname=&quot;Practice&quot; table=&quot;practices&quot;&gt;
	&lt;!--- tie this column back to Doctor.practice_id ---&gt;
	&lt;cfproperty name=&quot;id&quot; column=&quot;practice_id&quot; fieldtype=&quot;id&quot; generator=&quot;foreign&quot; params=&quot;{property='Doctor'}&quot;&gt;

	&lt;!--- Relate locations to this practice via Locations.practice_id and Locations.active = 1 ---&gt;
        &lt;cfproperty name=&quot;locations&quot; type=&quot;array&quot; fieldtype=&quot;one-to-many&quot; cfc=&quot;Location&quot; fkcolumn=&quot;practice_id&quot; params=&quot;{property='Location'}&quot; where=&quot;active = 1&quot;&gt;

    &lt;cfproperty name=&quot;name&quot; column=&quot;practice_name&quot;&gt;
    &lt;cfproperty name=&quot;active&quot; column=&quot;active&quot;&gt;
&lt;/cfcomponent&gt;
</pre>
<p><strong>location.cfc</strong></p>
<pre class="brush: coldfusion;">
&lt;cfcomponent persistent=&quot;true&quot; entityname=&quot;Location&quot; table=&quot;locations&quot;&gt;
	&lt;cfproperty name=&quot;id&quot; column=&quot;location_id&quot; fieldtype=&quot;id&quot;&gt;

	&lt;cfproperty name=&quot;practice_id&quot; column=&quot;practice_id&quot;&gt;

    &lt;cfproperty name=&quot;address1&quot; column=&quot;address1&quot;&gt;
    &lt;cfproperty name=&quot;address2&quot; column=&quot;address2&quot;&gt;
    &lt;cfproperty name=&quot;city&quot; column=&quot;city&quot;&gt;
    &lt;cfproperty name=&quot;state&quot; column=&quot;state&quot;&gt;
    &lt;cfproperty name=&quot;zipcode&quot; column=&quot;zipcode&quot;&gt;
    &lt;cfproperty name=&quot;phone&quot; column=&quot;phone&quot;&gt;
    &lt;cfproperty name=&quot;active&quot; column=&quot;active&quot;&gt;
&lt;/cfcomponent&gt;
</pre>
<p>At this point we have three ORM entities that are mapped to the three database tables.  If you look closely, you&#8217;ll notice that relationships have also been defined for doctors to practice, and practice to locations.  Setting up the relationships at the mapping level takes care of physically joining the three tables together via sql.  Also, while it&#8217;s pretty straight forward reading a blog with working code, I&#8217;m not going to pretend I got these relationships setup first try.  It&#8217;s simple relating two tables together, but finding the right combination for doctror &gt; practice &gt; locations was tricky.  I did a lot of this to figure this part out.</p>
<pre class="brush: coldfusion;">
&lt;cfscript&gt;
// load doctors
dr_list = ORMExecuteQuery( &quot;FROM Doctor WHERE status = 'Active' AND provider_id = 1&quot; );
// load a practice
// practice = ORMExecuteQuery( &quot;FROM Practice WHERE practice_id = 1&quot; );
// load a location
// location = ORMExecuteQuery( &quot;FROM Location&quot; );
&lt;/cfscript&gt;

&lt;cfdump var=&quot;#dr_list#&quot; /&gt;
&lt;cfabort /&gt;
</pre>
<p><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">You can find out more about <a title="How to define relationships with Coldfusion9 ORM" href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS5FFD2854-7F18-43ea-B383-161E007CE0D1.html" target="_blank">defining ORM relationships on this livedocs page</a>.</span></p>
<p>With the hard stuff out of the way, we&#8217;re down to two steps.  First it&#8217;s time to port my cfquery that grabs the data, and the cffunction that converts the query into our loopable doctor structure.  Are you ready for this?</p>
<pre class="brush: coldfusion;">
dr_list = ORMExecuteQuery( &quot;from Doctor WHERE status = 'Active' AND is_midlevel = 0 ORDER BY last_name, first_name&quot; );
</pre>
<p>To give you the full idea of how much code was shrunk down to a single line, here are the two cffunctions used to query and massage the data into a useable structure.</p>
<pre class="brush: coldfusion;">
	&lt;!--- Retrieve listing of all active providers in the app  ---&gt;
    &lt;cffunction name=&quot;getAllActiveProviders&quot; access=&quot;public&quot; returntype=&quot;struct&quot;&gt;

		&lt;cfquery name=&quot;providers_qry&quot; DATASOURCE=&quot;#request.dsn#&quot; USERNAME=&quot;#request.dbuser#&quot; PASSWORD=&quot;#request.dbpswd#&quot;&gt;
            SELECT	DISTINCT

					p.provider_id,
            		CONCAT( p.first_name, ' ', p.last_name ) AS 'full_name',
                    p.first_name,
                    p.last_name,

    	            p2.practice_name,

					l.address1,
                    l.address2,
                    l.city,
                    l.state,
                    l.zipcode,
                    l.phone

            FROM	providers p, practices p2

            LEFT OUTER JOIN locations l
            ON p2.practice_id = l.practice_id AND l.active = 1

            WHERE	p.status = 'Active'
            AND		p.practice_id = p2.practice_id
            AND		is_midlevel = 0

            ORDER BY	p.last_name, p.first_name
        &lt;/cfquery&gt;

		&lt;!--- return a translated structure ---&gt;
		&lt;cfreturn providersQryToStruct( providers_qry ) /&gt;

    &lt;/cffunction&gt;

	&lt;!--- Translates the providers query into a Struct that has a row per doctor, each containing an Array for location(s) ---&gt;
	&lt;cffunction name=&quot;providersQryToStruct&quot; access=&quot;public&quot; returntype=&quot;struct&quot;&gt;

    	&lt;cfargument name=&quot;providers_qry&quot; type=&quot;query&quot; required=&quot;yes&quot;&gt;

		&lt;cfscript&gt;
		this_dr = &quot;&quot;;
		last_dr = &quot;&quot;;
		// array of provider arrays
		providers_struct = StructNew();

		// loop through qry and flatten into single row with Location = Array
		// The key to this qry is provider_name+provider_id
		for( xx = 1; xx &lt;= providers_qry.RecordCount; xx++ )
		{
			// set key to this row [ LAST_NAME+FIRST_NAME+PROVIDER_ID ]
			this_dr = providers_qry.LAST_NAME[ xx ] &amp; providers_qry.FIRST_NAME[ xx ] &amp; providers_qry.PROVIDER_ID[ xx ];

			// clean up DR name
			this_dr = Replace( this_dr, &quot; &quot;, &quot;&quot; );
			this_dr = Replace( this_dr, &quot;,&quot;, &quot;&quot; );
			this_dr = Replace( this_dr, &quot;.&quot;, &quot;&quot; );

			// got same doctor?
			if( this_dr != last_dr )
			{
				// append to array
				provider = StructNew();
				// FILL UP PROVIDER
				provider['full_name'] = providers_qry[&quot;full_name&quot;][ xx ];
				provider['practice_name'] = providers_qry['practice_name'][ xx ];

				// location array
				provider['location'] = ArrayNew(1);

				// add first location
				loc = StructNew();
				loc['address1']	 = providers_qry['address1'][ xx ];
				loc['address2']	 = providers_qry['address2'][ xx ];
				loc['city']		 = providers_qry['city'][ xx ];
				loc['state']	 = providers_qry['state'][ xx ];
				loc['zipcode']	 = providers_qry['zipcode'][ xx ];
				loc['phone']	 = providers_qry['phone'][ xx ];

				// add location struct to array
				ArrayAppend( provider['location'], loc );

				// Add to master struct
				providers_struct[ this_dr ] = provider;
			}
			else
			{
				// add first location
				loc = StructNew();
				loc['address1']	 = providers_qry['address1'][ xx ];
				loc['address2']	 = providers_qry['address2'][ xx ];
				loc['city']		 = providers_qry['city'][ xx ];
				loc['state']	 = providers_qry['state'][ xx ];
				loc['zipcode']	 = providers_qry['zipcode'][ xx ];
				loc['phone']	 = providers_qry['phone'][ xx ];

				// Append to this DR's location array
				ArrayAppend( providers_struct[ this_dr ]['location'], loc );
			}

			// store this_dr in last_dr for next iteration
			last_dr = this_dr;
		}

		return providers_struct;
        &lt;/cfscript&gt;

    &lt;/cffunction&gt;
</pre>
<p>After going through the brain fry of figuring out ORM relationships, replacing over one hundred lines of code with only a single line really made my day.  Now it was time for the final step, porting the cfml that draws the html table into using the ORM collection instead.<br />
The porting of the cfml that draws the doctor table was a piece of cake.  The updates were so easy it was almost not worth showing, but I&#8217;m including just to complete the picture.</p>
<p><strong>The original sql loop code</strong></p>
<pre class="brush: coldfusion;">
    &lt;!--- use dr_list as sorted list. use each DR key to pick out data from providers_struct ---&gt;
    &lt;cfloop list=&quot;#dr_list#&quot; index=&quot;xx&quot;&gt;
    &lt;tr&gt;

        &lt;td&gt;#providers_struct[ xx ]['full_name']#&lt;/td&gt;

        &lt;td&gt;#providers_struct[ xx ]['practice_name']#&lt;/td&gt;

        &lt;td&gt;
        &lt;!--- loop through array of location structures ---&gt;
        &lt;cfloop from=&quot;1&quot; to=&quot;#ArrayLen( providers_struct[ xx ]['location'] )#&quot; index=&quot;yy&quot;&gt;
            &lt;address&gt;
            &lt;cfset loc = #providers_struct[ xx ]['location'][ yy ]#&gt;
            &lt;li&gt;#loc.address1#, #loc.address2#
            #loc.city#, #loc.state# #loc.zipcode#
            &lt;br /&gt;
            &lt;b&gt;#loc.phone#&lt;/b&gt;
            &lt;/li&gt;
            &lt;/address&gt;
        &lt;/cfloop&gt;
        &lt;/td&gt;

    &lt;/tr&gt;
    &lt;/cfloop&gt;
</pre>
<p><strong>The new ORM loop code</strong></p>
<pre class="brush: coldfusion;">
	&lt;!--- loop through parent query ---&gt;
    &lt;cfloop array=&quot;#dr_list#&quot; index=&quot;xx&quot;&gt;
    &lt;tr&gt;

    	&lt;!--- retrieve properties using ORM's getProperty() syntax ---&gt;
        &lt;td&gt;#xx.getFirstName()# #xx.getLastName()#&lt;/td&gt;

        &lt;td&gt;#xx.getPractice().getName()#&lt;/td&gt;

        &lt;td&gt;
		&lt;!--- loop through locations collection Doctor &gt; Practice &gt; Location(s)  ---&gt;
        &lt;cfloop array=&quot;#xx.getPractice().getLocations()#&quot; index=&quot;loc&quot;&gt;

            &lt;address&gt;
                &lt;li&gt;#loc.getAddress1()#, #loc.getAddress2()#
                #loc.getCity()#, #loc.getState()# #loc.getZipcode()#
                &lt;br /&gt;
                &lt;b&gt;#loc.getPhone()#&lt;/b&gt;
                &lt;/li&gt;
            &lt;/address&gt;

        &lt;/cfloop&gt;
        &lt;/td&gt;

    &lt;/tr&gt;
    &lt;/cfloop&gt;
</pre>
<p>A few things I&#8217;d like to point out in the new ORM loop code</p>
<ol>
<li>ORMExecuteQuery returned a data collection that I can loop through without post-processing</li>
<li>When retrieving object properties, use the get<strong>PropertyName</strong>() syntax.  EX : doctor.getFirstName() instead of doctor.FirstName</li>
<li>Practice.locations was declared as an Array collection, but you could use Structure as well.</li>
<li>To get the ORMExecuteQuery record count, use ArrayLen.</li>
</ol>
<h2>Did ORM make this easier?</h2>
<p>I&#8217;d say yes it did.  Mapping my tables via code, including the relationships, really saved time writing SQL.  Funny thing, while I was porting this over, I actually found a few data and code bugs in the home grown solution that I didn&#8217;t catch before.  Once the dust had settled I still had one difference in the home grown versus ORM code, and that turned out to be duplicated location rows.</p>
<p>The other thing that I noticed thanks to our good friend cfdump, is all the extra functionality that comes along with the objects returned from ORM.  On top of having a populated data object, you also have magical getters, setters, and other useful methods to work with your data objects.  To see what I mean, fire an ORMExecuteQuery and run your variable through CFDUMP.</p>
<p>To sum up, I&#8217;m really starting to buy into using ORMs.  Since I know and love SQL, I&#8217;ve been anti ORM for too long.  Having said that, I&#8217;m not fully advocating going ORM for everything.  Pretty much every project I work on these days is powered by some datasource, but I don&#8217;t really need all the ORM baggage for simple sites.  Now for large applications, or any site large enough to need at least two people, I&#8217;d give ORM a chance.  I still have lots of ins and outs to learn about using Hibernate, but it is definitely simple enough to get jamming right away.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2009/12/i-wonder-if-using-coldfusion9s-orm-would-make-this-easier/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
