<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Chris Haas&#039;s Blog</title>
	<atom:link href="http://chrishaas.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrishaas.wordpress.com</link>
	<description>Basically a place that Chris can post solutions to problems so he can easily find them later</description>
	<lastBuildDate>Mon, 07 Dec 2009 17:08:04 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='chrishaas.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/9d64b1fa33f9173fc7c4c9e505792fc9?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Chris Haas&#039;s Blog</title>
		<link>http://chrishaas.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://chrishaas.wordpress.com/osd.xml" title="Chris Haas&#039;s Blog" />
		<item>
		<title>Fixing a Linksys SD2008 running at 100 Mbps</title>
		<link>http://chrishaas.wordpress.com/2009/12/07/fixing-a-linksys-sd2008-running-at-100-mbps/</link>
		<comments>http://chrishaas.wordpress.com/2009/12/07/fixing-a-linksys-sd2008-running-at-100-mbps/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 17:08:04 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=83</guid>
		<description><![CDATA[We were having some networking issues at work where our Macs had problems with our Widows 2003 R2 file server. They could connect just fine but browsing was just painfully slow and file transfers were hit or miss. Our Vista and XP machines were running just fine. Googling turned up a command line you could [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=83&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We were having some networking issues at work where our Macs had problems with our Widows 2003 R2 file server. They could connect just fine but browsing was just painfully slow and file transfers were hit or miss. Our Vista and XP machines were running just fine. Googling turned up a <a href="http://www.small-tree.com/kb_results.asp?ID=1" target="_blank">command line</a> you could try but that didn&#8217;t work for us. I found that manually setting the gigabit-based machines to 100TX seemed to fix the problems sometimes but not always. Eventually I traced the problem to a switch that when the Macs and the file server were connected to it would cause the problems. The quick fix was to put all Macs and the file server on the other switch but unfortunately that switch is only 100-based.</p>
<p>So then I brought in a friend to help and after a little standard troubleshooting we found that if we connected the server to the gigabit switch it reported that it was only connected at 100Mbps but if we plugged his laptop into the switch he got full gigabit. First thought &#8211; the wire. Unfortunately using the same wire that he tested with still resulted in 100Mbps for the server. Second thought &#8211; the port, but all ports acted the same. Third thought &#8211; the NIC. But, after swapping the NIC out for a known-good NIC we still only got 100Mbps.</p>
<p>Both NICs that we were using were Intel Pro/1000 GT Desktop adapters with Windows-supplied drivers so we tried upgrading to the latest drivers from Intel. Thankfully they came with a diagnostic utility that after we ran it reported &#8220;The cable connected to this port is missing pairs needed to connect at 1000 Mbps&#8221;. So now we were pretty confident that the problem was with the switch but in my experience switches either are working, have dead ports or are just plain dead. I&#8217;d never run across a switch &#8220;partially working&#8221;. After a little more Googling I found an <a href="http://www.legitreviews.com/article/785/1/" target="_blank">article</a> that talked about &#8220;bulging capacitors&#8221; on Linksys SD2008 models caused by overheating. So I finally <a href="http://www.thinkgeek.com/tshirts-apparel/unisex/generic/8f52/" target="_blank">cracked the Linksys SD2008 open</a> and found that indeed I had four bulging capacitors.</p>
<div class="wp-caption alignnone" style="width: 490px"><a href="http://406coupe.net/archives/000078.html" target="_blank"><img title="Bulging Capacitor" src="http://406coupe.net/archives/06030801.jpg" alt="Bulging Capacitor" width="480" height="360" /></a><p class="wp-caption-text">In the image on the right, the center capacitor is “bulging”. (This image is not from my Linksys but shows a good close-up.)</p></div>
<p>The capacitors for my Linksys SD2008 were 470uf 25V so I ran out to RadioShack and picked up four 470uf 35V capacitors. (When purchasing capacitors its very important to match the capacitance which is measured in Farads (F) or microfarads (μF) exactly but the voltage doesn&#8217;t matter as long as it is equal or greater.) Using a soldering iron I pulled off all four and re-soldered on the new ones and then plugged everything back in. My new link tests now showed full gigabit! I then tested the Macs and they showed full gigabit as well as having zero problems with file transfer and browsing! Sweet!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=83&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/12/07/fixing-a-linksys-sd2008-running-at-100-mbps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>

		<media:content url="http://406coupe.net/archives/06030801.jpg" medium="image">
			<media:title type="html">Bulging Capacitor</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing MySql &#8220;Can&#8217;t create table (errno: 150)&#8221;</title>
		<link>http://chrishaas.wordpress.com/2009/12/01/fixing-mysql-cant-create-table-errno-150/</link>
		<comments>http://chrishaas.wordpress.com/2009/12/01/fixing-mysql-cant-create-table-errno-150/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 19:15:37 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=81</guid>
		<description><![CDATA[I got this while trying to create a foreign key in MySql. Once you see the fix its obvious. My parent table&#8217;s primary key was declared as UNSIGNED while my child table wasn&#8217;t. Change one or the other to match and you&#8217;re all set. I really which the MySql people would sit down and take [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=81&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I got this while trying to create a foreign key in MySql. Once you see the fix its obvious. My parent table&#8217;s primary key was declared as <code>UNSIGNED</code> while my child table wasn&#8217;t. Change one or the other to match and you&#8217;re all set. I really which the MySql people would sit down and take a moment to write out better error messages. Something as simple as &#8220;datatypes must match&#8221; would have really helped me.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=81&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/12/01/fixing-mysql-cant-create-table-errno-150/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Email Marketing Checklist</title>
		<link>http://chrishaas.wordpress.com/2009/11/03/email-marketing-checklist/</link>
		<comments>http://chrishaas.wordpress.com/2009/11/03/email-marketing-checklist/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 19:27:05 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Email Marketing]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=76</guid>
		<description><![CDATA[Here&#8217;s the rules that I follow when producing an HTML Email. Some of these rules may seem obvious, some may seem stupid and some may go against everything you may have learned about web standards, best practices, semantic html and accessibility. This last one is a hard thing to accept. And trust me, I&#8217;m all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=76&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here&#8217;s the rules that I follow when producing an HTML Email. Some of these rules may seem obvious, some may seem stupid and some may go against everything you may have learned about web standards, best practices, semantic html and accessibility. This last one is a hard thing to accept. And trust me, I&#8217;m all about those things when it comes to building web sites and web pages but the #1 rule of all is that <em><strong>EMAILS ARE NOT WEB PAGES!</strong></em> They just look like them and are built the same way. But whereas a web page may be viewed on 3 to 6 primary browsers, emails are viewed many, many more.</p>
<p>First you have the email clients, Outlook 2007/2003, Entourage 2008/2004, Lotus Notes 6.5/7/8, Outlook Express, Windows Mail, Apple Mail and Thunderbird. In my experience, these are the most common currently. There&#8217;s also many other POP3/IMAP clients but I don&#8217;t encounter them too often. (Yes, I know you use them, but if you&#8217;re reading this you&#8217;re not the target audience I work with usually). Second you have the wonderful web-based clients such as MSN, Yahoo, Gmail and the wonderful OWA. Multiply these clients by your expected browser/platform combinations, too, because OWA IE is completely different than OWA Firefox. Third, don&#8217;t forget about people that don&#8217;t have images turned on. These people need a reason to download your creative and if your email can&#8217;t be understood without images it might just get skipped. And last there&#8217;s the text-based email which isn&#8217;t used too much anymore but should still be considered.</p>
<p>Anyway, here&#8217;s my list. Its by no means complete and will always be growing so check back often for updates.</p>
<p><strong>HTML/CSS</strong></p>
<ul>
<li>100% XHTML Transitional compliant
<ul>
<li><a href="http://validator.w3.org/">http://validator.w3.org/</a></li>
</ul>
</li>
<li>ISO-8859-1 encoding
<ul>
<li>NOT UTF-8 despite normal best practices</li>
<li>All characters above ASCII 127 must be HTML-encoded</li>
</ul>
</li>
<li>ALL CSS must be inline (style=”…”)
<ul>
<li>The exception is to have style in the header for a:pseudo tags but they must only be used to provide additional rules for anchors such as hover and visited</li>
</ul>
</li>
<li>Entire email must be wrapped in 100% wide table whose background matches the body’s background</li>
<li>Email should be table-based
<ul>
<li>Avoid floats, use padding and margins sparingly</li>
</ul>
</li>
<li>Text-based styles should be applied to parent &lt;td&gt; tag. Outlook does not<strong> </strong>pass styles to child &lt;td&gt; tags so you must re-apply them to children.</li>
<li>Avoid using &lt;p&gt; tags for paragraphs, instead use &lt;br /&gt;&lt;br /&gt; to separate blocks of text</li>
<li>Make sure that all images have ALT text</li>
<li>All images must be absolutely linked</li>
<li>All images must use their true dimensions (you must not stretch an image, for instance a 1&#215;1 gif spacer, Outlook will use the true dimension and your creative will look weird)</li>
<li>Background images must not<strong><em> </em></strong>be used
<ul>
<li>The only exception is if it’s not important to the message and a backup background color is specified.</li>
</ul>
</li>
<li>Avoid soft-returns to fix widows, instead use non-breaking spaces between the last few words</li>
<li>All images should have the style display:block; applied to them otherwise Hotmail will render them with additional spaces</li>
</ul>
<p><strong>General</strong></p>
<ul>
<li>All emails must contain a postal address that can be used to send opt-outs to</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=76&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/11/03/email-marketing-checklist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing &#8220;The remote server returned an error: (417) Expectation Failed&#8221;</title>
		<link>http://chrishaas.wordpress.com/2009/11/02/fixing-the-remote-server-returned-an-error-417-expectation-failed/</link>
		<comments>http://chrishaas.wordpress.com/2009/11/02/fixing-the-remote-server-returned-an-error-417-expectation-failed/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 20:46:05 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=74</guid>
		<description><![CDATA[After failing at breakpointing and debugging request and response headers I almost snapped Wireshark to my connection to determine why I was getting an WebException of &#8220;The remote server returned an error: (417) Expectation Failed&#8220;. A little searching took me to this site with the solution. The simple solution is to set the static property [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=74&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After failing at breakpointing and debugging request and response headers I almost snapped Wireshark to my connection to determine why I was getting an <code>WebException</code> of &#8220;<code>The remote server returned an error: (417) Expectation Failed</code>&#8220;. A little searching took me to <a href="http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx" target="_blank">this</a> site with the solution. The simple solution is to set the static property <code>System.Net.ServicePointManager.Expect100Continue</code> to <code>False</code> before making your call.</p>
<p>Documentation of that property can be found <a href="http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.expect100continue.aspx" target="_blank">here</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=74&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/11/02/fixing-the-remote-server-returned-an-error-417-expectation-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Solving &#8220;The default script language specified for this application is invalid&#8221;</title>
		<link>http://chrishaas.wordpress.com/2009/10/21/solving-the-default-script-language-specified-for-this-application-is-invalid/</link>
		<comments>http://chrishaas.wordpress.com/2009/10/21/solving-the-default-script-language-specified-for-this-application-is-invalid/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 20:38:26 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ASP Classic]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=60</guid>
		<description><![CDATA[This was a pain in the butt. Like everyone else I tried registering things, unregistering things, deleting &#8220;MBSchema.bin.00000000h&#8221; and resetting permissions. None of that worked, or at least none of the entries people talked about. But maybe my problem was from running IIS on a 64-bit machine under 32-bit mode. So I fired up Process [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=60&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This was a pain in the butt. Like everyone else I tried registering things, unregistering things, deleting &#8220;MBSchema.bin.00000000h&#8221; and resetting permissions. None of that worked, or at least none of the entries people talked about. But maybe my problem was from running IIS on a 64-bit machine under 32-bit mode. So I fired up <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" target="_blank">Process Monitor</a> and watched for some <code>ACCESS DENIED</code> error messages. Right away I found <code>w3wp.exe</code> had a problem accessing <code>HKCR\Wow6432Node\VBScript</code>. I tried giving <code>IUSR_MACHINE</code> the Read permission but that didn&#8217;t seem to work. In the end I just decided to give <code>Users</code> and <code>Everyone</code> both Read access to that key. And voila, it worked.</p>
<p>This machine hadn&#8217;t been updated in a while and yesterday while connecting to Windows Update we were getting a 0&#215;80070020 error message. After fixing that (a whole other story) we installed a bunch of patches but apparently didn&#8217;t notice that they took down our other sites. I&#8217;m guessing that somewhere in the middle of the night that the app pools recycled from inactivity because someone would have said something yesterday if they were down. Unfortunately I&#8217;m too lazy to go through my logs to figure out what was all applied yesterday so I can&#8217;t blame a specific patch and I don&#8217;t really care to, either.</p>
<p>After that problem we were getting 8002801d error messages from ASP. After monkeying around for a while I stumbled on a &#8220;Microsoft FixIt&#8221; tool for this problem and that solved everything. When did these &#8220;Microsoft FixIt&#8221; things come out? When they work, they&#8217;re awesome!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=60&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/10/21/solving-the-default-script-language-specified-for-this-application-is-invalid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedding partial fonts in Adobe Flash CS3 for use in ActionScript 3 (AS3)</title>
		<link>http://chrishaas.wordpress.com/2009/10/21/embedding-partial-fonts-in-adobe-flash-cs3-for-use-in-actionscript-3-as3/</link>
		<comments>http://chrishaas.wordpress.com/2009/10/21/embedding-partial-fonts-in-adobe-flash-cs3-for-use-in-actionscript-3-as3/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:18:08 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Action Script]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Fonts]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=58</guid>
		<description><![CDATA[Long post title but its to help me remember it once and for all. I&#8217;ve lost too much time to font embedding in AS3 only to find that I&#8217;ve tested it on a machines with the fonts installed and the embedding isn&#8217;t actually working. I&#8217;m not going to go into super detail about it, I&#8217;m [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=58&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Long post title but its to help me remember it once and for all. I&#8217;ve lost too much time to font embedding in AS3 only to find that I&#8217;ve tested it on a machines with the fonts installed and the embedding isn&#8217;t actually working. I&#8217;m not going to go into super detail about it, I&#8217;m assuming that you&#8217;ve got it 99% of the way and are struggling (and swearing) because it doesn&#8217;t stick.</p>
<p>First, some don&#8217;ts:</p>
<ul>
<li>Don&#8217;t use the library. The library is for full font embedding &#8211; not partial &#8211; and can increase your file by 20 to 30 KB (or more if you&#8217;ve got a Unicode font!)</li>
<li>Don&#8217;t use <code>[Embed(source="C:\WINDOWS\Fonts\somefont.ttf", fontFamily="foo")]</code>. I don&#8217;t even know if that works but I assume that if it did it would embed the full font which would lead to the previous problem.</li>
</ul>
<p>Now the process:</p>
<ol>
<li>Draw a text field on the canvas but off the stage and set it to Dynamic Text</li>
<li>Set the text field&#8217;s font to the font that you want to embed
<ul>
<li>You may or may not have to set the size to what you want to use, haven&#8217;t tested that yet</li>
</ul>
</li>
<li>Press the embed button in the Properties palette  and select your characters.
<ul>
<li>Don&#8217;t forget to include any and all punctuation characters that you&#8217;re using.</li>
<li>Consider maintenance &#8211; is it worth 2KB to exclude a couple of letters you&#8217;re not using now only to forget in a couple of months how to add them? Maybe you should just add all of A-Z.</li>
<li>If you type your own in don&#8217;t forget to include the space character!</li>
</ul>
</li>
<li>In your code, reference the font using the exact same name that&#8217;s in the dynamic text field&#8217;s font menu
<ul>
<li>In fact, copy it out of the menu. I once had a font with two spaces side-by-side in the name. Several hours were wasted on that.</li>
<li><code>var NavItemTextFormat_MouseOff:TextFormat = new TextFormat("Aviano Sans Bold", 12,0x000000,true,false,false,null,null,TextFormatAlign.RIGHT);</code></li>
</ul>
</li>
<li>Last and most important, after you call <code>setTextFormat()</code> on your <code>TextField</code>, you also have to set the <code>embedFonts</code> to <code>true</code><br />
<code>NavItem.setTextFormat(NavItemTextFormat_MouseOff);<br />
NavItem.embedFonts = true;</code></li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=58&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/10/21/embedding-partial-fonts-in-adobe-flash-cs3-for-use-in-actionscript-3-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Zero-Width HTML Space</title>
		<link>http://chrishaas.wordpress.com/2009/07/23/zero-width-html-space/</link>
		<comments>http://chrishaas.wordpress.com/2009/07/23/zero-width-html-space/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 19:58:20 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=56</guid>
		<description><![CDATA[Let&#8217;s say you have the text &#8220;Life insurance/Dependent Life&#8221; and you want to fit it into a small space with a small font. If you try it normally, most browsers might break the text so that it looks like:
Life
insurance/Dependent
Life
One solution is to just replace the forward slashes with a forward slash followed by a space [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=56&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Let&#8217;s say you have the text &#8220;<code>Life insurance/Dependent Life</code>&#8221; and you want to fit it into a small space with a small font. If you try it normally, most browsers might break the text so that it looks like:</p>
<p>Life<br />
insurance/Dependent<br />
Life</p>
<p>One solution is to just replace the forward slashes with a forward slash followed by a space giving you &#8220;<code>Life insurance/ Dependent Life</code>&#8220;. Not the end of the world but not ideal, I&#8217;d rather it break at the slashes. That&#8217;s where the <a href="http://en.wikipedia.org/wiki/Zero_Width_Space">zero-width space character</a> (<code>U+200B</code>) comes in. You can replace the forward slash with a forward slash followed by <code>&#8203;</code> and if the browser needs to, it will break at the forward slash, otherwise it will display the slash with no white space around it.</p>
<p>The bad news is that IE6 doesn&#8217;t know what to do with that character. The good news is that with a little javascript you can replace that character (and the even better news, after August 22<sup>nd</sup> hopefully most people will be upgraded to IE8). In my case, only my hyperlinks use this trick so below I&#8217;m searching for only <code>&lt;a&gt;</code> tags.</p>
<pre><code>
    if (navigator.userAgent.indexOf('MSIE 6.') &gt; 0) {
        var as = document.getElementsByTagName('a');
        var p = /\u200b/g;
        for (var i = as.length - 1; i &gt;=0 ; i--) {
            if (p.test(as[i].innerHTML)) {
                as[i].innerHTML = as[i].innerHTML.replace(p, '&lt;wbr/&gt;');
            }
        }
    }
</code></pre>
<p>You may notice that I&#8217;m walking backwards through the array (and that I don&#8217;t like <code>--i</code>), and to be honest I&#8217;m not sure why but going forwards didn&#8217;t catch all of the occurrences. Also, in case you&#8217;re wondering, I use this in my L3 navigation so I don&#8217;t have to worry about monkeying with my web.sitemap file figuring <em>exactly</em> how to break things. It does cause a little jump to occur in IE6 because I&#8217;m calling the JS onload but that&#8217;s okay with me.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=56&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/07/23/zero-width-html-space/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a simple multi-threaded VB.Net application</title>
		<link>http://chrishaas.wordpress.com/2009/06/25/creating-a-simple-multi-threaded-vb-net-application/</link>
		<comments>http://chrishaas.wordpress.com/2009/06/25/creating-a-simple-multi-threaded-vb-net-application/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 16:41:24 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=53</guid>
		<description><![CDATA[I write lots of desktop tools that help me do my job more efficiently. For instance, I&#8217;m normalizing a 98 million row live table and do to the nature of the server, table locks, etc, I&#8217;ve decided to pull the data down in batches using a VB.Net app, analyze it and perform a batch update. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=53&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I write lots of desktop tools that help me do my job more efficiently. For instance, I&#8217;m <a href="http://chrishaas.wordpress.com/2009/06/24/make-sure-your-sql-queries-are-using-the-proper-index/">normalizing a 98 million row live table</a> and do to the nature of the server, table locks, etc, I&#8217;ve decided to pull the data down in batches using a VB.Net app, analyze it and perform a batch update. The high-level code is simple: pull the data, group it and then execute some <code>UPDATE</code> SQL statements. But 98 million rows in a partially non-indexed table takes a looooong time, and maybe its my agency background, but I want some feedback as to what&#8217;s going on, and I want more than just a Trace/Console output. At first glance you might just add a progress bar and update it every time you do something, but unfortunately your code loop will block the UI thread from updating until complete (although you can throw some <code>Application.DoEvents</code> in there).</p>
<p>So enter multi-threading. If you think this is overkill then a) you obviously don&#8217;t know me and b) I&#8217;ve been doing this for years, it only takes a little bit more work to add it. The code below will show you how to create a multi-threaded app with a responsive UI. The code below is all done in Visual Basic 2008 Express Edition.</p>
<p>1) Create a new VB.Net Windows Forms Application.<br />
2) Add a ProgressBar and a Button to the form, leave the names the default names<br />
3) Resize the ProgressBar so you can see more of it<br />
4) Double-click the Button to go into code-behind<br />
5) Add a new class to the project called &#8220;Worker&#8221; and add the following code to it:</p>
<pre><code>
Option Explicit On
Option Strict On

Public Class Worker
    Private _curRun As Integer
    Private _maxRuns As Integer
    Public ReadOnly Property CurRun() As Integer
        Get
            Return Me._curRun
        End Get
    End Property
    Public ReadOnly Property MaxRuns() As Integer
        Get
            Return Me._maxRuns
        End Get
    End Property
    Public Sub New(ByVal maxRuns As Integer)
        Me._maxRuns = maxRuns
    End Sub
    Public Sub Start()
        For Me._curRun = 1 To Me._maxRuns
            System.Threading.Thread.Sleep(250)
        Next
    End Sub
End Class
</code></pre>
<p>This code will be doing our primary work. In this case its not actually doing anything except sleeping, you&#8217;ll want to replace the <code>System.Threading.Thread.Sleep(250)</code> with your own logic, obviously. We&#8217;ll instantiate this code in our primary UI thread later, telling it how many times we want it to loop. I always prefer to pass my required variables in the constructor and make them read-only properties so that I know that they&#8217;ll be set. One other thing that you&#8217;ll notice, usually in the <code>For</code> loop you&#8217;d do something like <code>For I = 1 to Me._maxRuns</code>, creating a local counter variable. Instead, our code creates a class-level variable and gives read-only permission to it so that other code (on another thread) can determine where we&#8217;re at. That&#8217;s it from the worker class&#8217;s point of view. The only bit of thread-related code in here is the <code>Sleep</code> method and that&#8217;s for example purposes only.</p>
<p>The next step is to add some logic to the main form&#8217;s code-behind to create our worker, create a thread to execute the worker and create a thread to monitor the worker and report back to the form and changes. Before I slap the code up let me explain how it will work. After clicking the button the form&#8217;s primary (and only, initially) thread will create an instance of the Worker class. It will then create a new Thread object and tell it that when we execute it it should call the Worker&#8217;s <code>Start()</code> method. This alone would give you a responsive UI but unfortunately the Worker thread can&#8217;t safely update the UI because they&#8217;re on different threads (and VS 2008 will actually throw errors if you try). You can get around this using events or delegates in the worker object but I prefer to make my worker object 100% completely thread un-aware, meaning that it doesn&#8217;t report back to anyone, it just does the work and if someone wants to inspect its progress, fine, but it doesn&#8217;t really care. So how do we do this? We introduce a third thread whose only job is to check the status of the worker object and tell the main thread to update the progress bar. The code is so simple that I don&#8217;t even bother wrapping it in a separate class, I just include a <code>Monitor()</code> method in the form&#8217;s code-behind. The code runs a loop until the worker thread signals that its done, sleeping for a bit between each loop so that we don&#8217;t flood the UI with update calls (there&#8217;s no sense in sending &#8220;set the progress bar to 1&#8243; a million times a second). Threads automatically handle adjusting their <code>ThreadState</code> so we don&#8217;t have to worry about that.</p>
<p>One of the things that takes a little bit of getting used to is the concept that one thread cannot modify controls on another thread. So our <code>Monitor()</code> method can&#8217;t actually update the UI. Instead what it does is ask the UI thread to update the UI on behalf of the monitor thread. I know, sounds weird. To do this, our <code>UpdateUI</code> method first calls <code>Me.InvokeRequired</code> which basically asks the form to check if the code calling this method is on the same thread. If its on the same thread it just adjust the progress bar. If its not on the same thread it ask the form to call the same method with the same parameters on its behalf using the <code>Invoke()</code> method. <code>Invoke</code> takes two parameters although the second is optional. The first is a delegate which is basically a type-safe function pointer. If you were using Javascript this would be the same as passing the function&#8217;s name without parentheses or just using the <code>function(){}</code> syntax. The second is an array of objects that represent the parameters to pass to the method. The syntax may look confusing but that&#8217;s just VB&#8217;s way of declaring an array. I think they&#8217;re fixing that in VB10 but I&#8217;m not sure. We also use a similar concept when the main thread is done to re-enable the button. And that&#8217;s it.</p>
<pre><code>
Option Explicit On
Option Strict On

Imports System.Threading

Public Class Form1
    Private MonitorThread As Thread
    Private WorkerThread As Thread
    Private W As Worker
    Private Delegate Sub UpdateUIDelegate(ByVal curIndex As Integer)
    Private Delegate Sub WorkerDoneDelegate()

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Button1.Enabled = False                      'Disable the button
        W = New Worker(50)                              'Create our Worker object
        Me.ProgressBar1.Maximum = W.MaxRuns             'Set the maximum value of the progress bar
        WorkerThread = New Thread(AddressOf W.Start)    'Create our Worker thread and tell it that when we start it it should call our Worker's Start() method
        MonitorThread = New Thread(AddressOf Monitor)   'Create our Monitor thread and tell it that when we start it it should call this class's Monitor() method
        WorkerThread.Start()                            'Start the worker thread
        MonitorThread.Start()                           'Start the monitor thread
    End Sub
    Private Sub Monitor()
        Do While WorkerThread.ThreadState &lt;&gt; ThreadState.Stopped    'Loop until the Worker thread (and thus the Worker object's Start() method) is done
            UpdateUI(W.CurRun)                                      'Update the progress bar with the current value
            Thread.Sleep(250)                                       'Sleep the monitor thread otherwise we'll be wasting CPU cycles updating the progress bar a million times a second
        Loop
        WorkerDone()                                                'If we're here, the worker object is done, call a method to do some cleanup
    End Sub
    Private Sub UpdateUI(ByVal curIndex As Integer)
        If Me.InvokeRequired Then                                                           'See if we need to cross threads
            Me.Invoke(New UpdateUIDelegate(AddressOf UpdateUI), New Object() {curIndex})    'If so, have the UI thread call this method for us
        Else
            Me.ProgressBar1.Value = curIndex                                                'Otherwise just update the progress bar
        End If
    End Sub
    Private Sub WorkerDone()
        If Me.InvokeRequired Then                                                           'See if we need to cross threads
            Me.Invoke(New WorkerDoneDelegate(AddressOf WorkerDone))                         'If so, have the UI thread call this method for us
        Else
            Me.Button1.Enabled = True                                                       'Otherwise just update the button
        End If
    End Sub
End Class
</code></pre>
<p>One last thing. Debugging a multi-threaded program can be a PITA so one of the things that I do is include a switch to turn it on or off as needed. I prefer to do this with a Compiler Directive by adding <code>#Const MULTI_THREADED = True</code> to the top of my code-behind. Then there&#8217;s just a simple change to the button&#8217;s click event:</p>
<pre><code>
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Button1.Enabled = False                      'Disable the button
        W = New Worker(50)                              'Create our Worker object
#If MULTI_THREADED Then
        Me.ProgressBar1.Maximum = W.MaxRuns             'Set the maximum value of the progress bar
        WorkerThread = New Thread(AddressOf W.Start)    'Create our Worker thread and tell it that when we start it it should call our Worker's Start() method
        MonitorThread = New Thread(AddressOf Monitor)   'Create our Monitor thread and tell it that when we start it it should call this class's Monitor() method
        WorkerThread.Start()                            'Start the worker thread
        MonitorThread.Start()                           'Start the monitor thread
#Else
        W.Start()
        Me.Button1.Enabled = True
#End If
    End Sub
</code></pre>
<p>When <code>MULTI_THREADED</code> is <code>False</code> we&#8217;ll invoke the worker, blocking the UI thread from ever updating, do the work and reset the button. This can save you a lot of time when debugging. This is also why I like to keep my worker object thread un-aware.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=53&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/06/25/creating-a-simple-multi-threaded-vb-net-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing &#8220;query processor ran out of stack space&#8221;</title>
		<link>http://chrishaas.wordpress.com/2009/06/25/fixing-query-processor-ran-out-of-stack-space/</link>
		<comments>http://chrishaas.wordpress.com/2009/06/25/fixing-query-processor-ran-out-of-stack-space/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 14:07:26 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[SQL Server 2000]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=49</guid>
		<description><![CDATA[I&#8217;ve been normalizing a table with 98 million rows for a couple of days now and with a recent change I&#8217;ve been able to run my batches in groups of 100,000 instead of just 10,000. The program doing the normalization pulls down 100,000 records at a time, analyzes and groups them and performs an UPDATE [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=49&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve been normalizing a table with 98 million rows for a couple of days now and with a <a href="http://chrishaas.wordpress.com/2009/06/24/make-sure-your-sql-queries-are-using-the-proper-index/" target="_self">recent</a> change I&#8217;ve been able to run my batches in groups of 100,000 instead of just 10,000. The program doing the normalization pulls down 100,000 records at a time, analyzes and groups them and performs an <code>UPDATE</code> for each item in the group, passing the primary keys back to the server in an <code>IN ()</code> clause. Everything was fine for a while but with the upgrade to 100,000 and with some groupings sending thousands of keys in the <code>IN</code> clause I started to get the following error:</p>
<pre><code>Internal Query Processor Error: The Query Processor Ran Out Of Stack Space During Query Optimization.</code></pre>
<p>Microsoft <a href="http://support.microsoft.com/kb/892141" target="_blank">says</a> to insert the keys into a temp table and join with that but that doesn&#8217;t really work for me. Instead I just decided to break up the <code>UPDATE</code> query into ones with more manageable <code>IN</code> clauses.</p>
<p>Originally I had something like:</p>
<pre><code>
            Dim mySQL = String.Format("UPDATE Tbl SET Col2=xyz WHERE Col1 IN ({0})", Join(TheList.ToArray(), ","))
            Using Com As New SqlCommand(mySQL, con)
                Com.CommandType = CommandType.Text
                Com.ExecuteNonQuery()
            End Using
</code></pre>
<p>The new code breaks things into more manageable sizes:</p>
<pre><code>
        Dim AmmountToProcess = 1000
        Do While True
            Dim Y = TheList.Take(AmmountToProcess)
            Dim mySQL = String.Format("UPDATE Tbl SET Col2=xyz WHERE Col1 IN ({0})", Join(Y.ToArray(), ","))
            Using Com As New SqlCommand(mySQL, con)
                Com.CommandType = CommandType.Text
                Com.ExecuteNonQuery()
            End Using
            TheList.RemoveRange(0, Math.Min(TheList.Count, AmmountToProcess))
            If TheList.Count = 0 Then Exit Do
        Loop
</code></pre>
<p>The new code uses the wonderful <a href="http://msdn.microsoft.com/en-us/library/bb503062.aspx" target="_blank"><code>Take</code></a> extension method to grab 1,000 items. <code>Take</code> luckily doesn&#8217;t error if you ask for more than available. The smaller <code>UPDATE</code> query runs and then we remove the first 1,000 items (or however many are left) from the list. Repeat until the list is empty.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=49&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/06/25/fixing-query-processor-ran-out-of-stack-space/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
		<item>
		<title>Make sure your SQL queries are using the proper index</title>
		<link>http://chrishaas.wordpress.com/2009/06/24/make-sure-your-sql-queries-are-using-the-proper-index/</link>
		<comments>http://chrishaas.wordpress.com/2009/06/24/make-sure-your-sql-queries-are-using-the-proper-index/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:00:18 +0000</pubDate>
		<dc:creator>chrishaas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL Server 2000]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://chrishaas.wordpress.com/?p=42</guid>
		<description><![CDATA[I&#8217;ve got a live table with 98 million rows that I&#8217;m normalizing. Unforuntately all full batch updates tend to lock the system for a very long so I wrote a VB.Net program to perform updates in smaller batches. The program pulls 10,000 records that haven&#8217;t been updated by using the standard SELECT TOP 10000… syntax. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=42&subd=chrishaas&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve got a live table with 98 million rows that I&#8217;m normalizing. Unforuntately all full batch updates tend to lock the system for a very long so I wrote a VB.Net program to perform updates in smaller batches. The program pulls 10,000 records that haven&#8217;t been updated by using the standard <code>SELECT TOP 10000…</code> syntax. Unfortunately the <code>WHERE</code> portion of this query takes a really long time to run. I started digging into things and tried just <code>SELECT TOP 1…</code> and that returned results immediately. I then tried <code>SELECT TOP 10…</code> and that returned immediately, too. After playing around I found that <code>SELECT TOP 63…</code> was the most I could go before the query took a long time to execute. I have no idea what&#8217;s so special about <code>63</code> but it was bugging me. So I ran <code>SELECT TOP 63…</code> and <code>SELECT TOP 64…</code> side-by-side in SQL SMS with the execution plan turned on and found the <code>63</code> version was using an Index Seek on the index that was on the column in my <code>WHERE</code> clause. This is a good thing. The <code>64</code> version, however, was performing a Clustered Index Scan on the primary key which had nothing to do with my <code>WHERE</code> clause.</p>
<p>The fix for this is to force SQL to use the index of your choice and its so easy to do. In your query, before the <code>WHERE</code> clause just add <code>WITH (INDEX(INDEX_NAME))</code>.</p>
<p>So if this is your original query:</p>
<pre><code>SELECT TOP 10000 Col1, Col2 FROM YourTable WHERE Col3 IS NULL</code></pre>
<p>And you have an index on <code>Col3</code> called <code>IDX__YourTable__Col3</code> you&#8217;d execute this query instead:</p>
<pre><code>SELECT TOP 10000 Col1, Col2 FROM YourTable <strong>WITH (INDEX(IDX__YourTable__Col3))</strong> WHERE Col3 IS NULL</code></pre>
<p>Normally you shouldn&#8217;t have to do this but if you&#8217;re doing one-off things like I&#8217;m doing it comes in handy.</p>
<p>&#8211;Update:</p>
<p>The forced index is running so fast that I&#8217;ve actually changed my batch size from 10,000 to 100,000. The prior 10,000 was processing about 400 records/sec, most of the time spent trying to get results from the <code>SELECT TOP…</code> but with the forced index and changing to 100,000 I&#8217;m now averaging 3,500 records/sec. Nice.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrishaas.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrishaas.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrishaas.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrishaas.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrishaas.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrishaas.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrishaas.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrishaas.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrishaas.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrishaas.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrishaas.wordpress.com&blog=8092262&post=42&subd=chrishaas&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://chrishaas.wordpress.com/2009/06/24/make-sure-your-sql-queries-are-using-the-proper-index/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/860cd8e5ee5064509d0ef587159804eb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrishaas</media:title>
		</media:content>
	</item>
	</channel>
</rss>