<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>MindFill - Brian Carroll's Blog</title><link>http://weblogs.asp.net/bkcarroll/default.aspx</link><description>Do While (WhatYouKnow) &lt; (WhatYouKnow + 1)</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Reading poorly formatted .NET code - made easy!</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/11/29/272017.aspx</link><pubDate>Tue, 30 Nov 2004 02:44:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:272017</guid><dc:creator>bkcarroll</dc:creator><slash:comments>15</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=272017</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/11/29/272017.aspx#comments</comments><description>&lt;p&gt;I downloaded a .NET app the other day and wondered how the author was accomplishing one piece of it.&amp;nbsp;&amp;nbsp;He had made the&amp;nbsp;source code&amp;nbsp;available for download, so&amp;nbsp;I downloaded it and started digging in.&amp;nbsp; But it didn't take me long&amp;nbsp;to realize the&amp;nbsp;the author had no style whatsoever - the code was a mess!&lt;/p&gt; &lt;p&gt;While I was reformatting&amp;nbsp;the code&amp;nbsp;to make it readable, I had a thought - it might be faster&amp;nbsp;to use&amp;nbsp;&lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;Lutz Roeder's .NET Reflector &lt;/a&gt;to disassemble the exe and then read the generated code.&amp;nbsp; I tried it and within a few minutes&amp;nbsp;I had found what I was looking for.&lt;/p&gt; &lt;p&gt;What an awesome tool!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=272017" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>Coder To Developer - Rave or Rage?</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/08/06/209864.aspx</link><pubDate>Fri, 06 Aug 2004 14:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:209864</guid><dc:creator>bkcarroll</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=209864</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/08/06/209864.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;I picked up a copy of Mike Gunderloy's Coder To Developer book the other day and did something I rarely do with a technical book - I read it from cover to cover.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;I've read several reviews of the book and find that they range from &lt;A href="http://weblogs.asp.net/mhawley/archive/2004/05/21/137855.aspx"&gt;rave &lt;/A&gt;to &lt;A href="http://weblogs.asp.net/grobinson/archive/2004/07/30/201658.aspx#202105"&gt;rage&lt;/A&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The typical "rage" review argues that the book is .NET-centric and has a short shelf life.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Personally, I think both of these points are what make me "rave" about the book. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;The book is definitely .NET-centric.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Since I'm also .NET-centric, this is exactly what I wanted - a book that covers what is relevant to my job.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;A quick scan of the book makes this clear, so no one should be surprised.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;As many other reviewers keenly point out, the book discusses a lot of tools and trends that are current today that may not be relevant next year.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Well, guess what - I'm writing software today!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And the better I understand the tools at my disposal today, the better I'll be able to write software that will be used tomorrow.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Sure, when I pickup this book in a couple of years the discussion of &lt;A href="http://www.fogcreek.com/FogBUGZ/"&gt;FogBUGZ &lt;/A&gt;may be outdated, but the concept of tracking bugs will be the same.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;Mike did an awesome job with this book.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;He covered concepts that are not only relevant for today's .NET developers, but will be relevant for years to come.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;He also introduced his readers to the tools available to us today that will help us develop better software for tomorrow.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=209864" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/General/default.aspx">General</category><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>How to determine when Windows started</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/07/20/188738.aspx</link><pubDate>Tue, 20 Jul 2004 14:55:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:188738</guid><dc:creator>bkcarroll</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=188738</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/07/20/188738.aspx#comments</comments><description>&lt;P&gt;Note to self (and anyone else interested)...&lt;/P&gt;
&lt;P&gt;To&amp;nbsp;determine when a&amp;nbsp;Windows system was started, issue the following command from a command prompt:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;net statistics server&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=188738" width="1" height="1"&gt;</description></item><item><title>SR2Fav - Utility to add SharpReader locked items to your IE Favorites</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/06/29/168794.aspx</link><pubDate>Tue, 29 Jun 2004 15:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:168794</guid><dc:creator>bkcarroll</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=168794</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/06/29/168794.aspx#comments</comments><description>&lt;P&gt;Although &lt;A href="http://www.sharpreader.net/"&gt;SharpReader &lt;/A&gt;doesn't have a lot of fancy bells and whistles, I keep coming back to it after trying the &amp;#8220;latest and greatest&amp;#8220; aggregators.&lt;/P&gt;
&lt;P&gt;Like most people, I don't have time to read everything that I subscribe to, so I tend to read the headinlines and&amp;nbsp;only drill into the&amp;nbsp;entries that sound interesting.&amp;nbsp; I may want to&amp;nbsp;refer back to some&amp;nbsp;entries later, so I lock those and&amp;nbsp;delete the rest.&amp;nbsp; Last night I was thinking it would be nice if I could add all of my locked items to my favorites list in IE.&amp;nbsp; Well, that sounded like fun, so I have put together this little utility that&amp;nbsp;reads my&amp;nbsp;SharpReader cache, creates a SharpReader folder in&amp;nbsp;my IE favorites list, creates subfolders for each of my subscriptions, and then creates a favorite for each locked item.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I've provided a link to it &lt;A href="http://www.dyadsoftware.com/pub/sr2fav.zip"&gt;here&lt;/A&gt;, so feel free to give it a test drive if you would like.&lt;/P&gt;
&lt;P&gt;If you have any questions I'll be glad to answer them if I can.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Again, I wrote this for myself, so the assumptions I was working under are:&lt;BR&gt;Windows XP w/IE 6&lt;BR&gt;SharpReader v0.9.4.1&lt;/P&gt;
&lt;P&gt;There are no guarantees that it will work&amp;nbsp;with your configuration, but I'll be glad to work with you in an attempt to resolve any issues.&lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=168794" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>Deleting an NTFS Partition from DOS</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/06/25/166321.aspx</link><pubDate>Fri, 25 Jun 2004 20:53:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:166321</guid><dc:creator>bkcarroll</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=166321</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/06/25/166321.aspx#comments</comments><description>&lt;P&gt;If you ever need to delete an NTFS partition from DOS, the &lt;A href="ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt31/i386/reskit.exe"&gt;Windows NT 3.1 Resource Kit &lt;/A&gt;has the solution.&amp;nbsp;&amp;nbsp;Download the kit, extract the DELPART.EXE utility to a DOS boot disk,&amp;nbsp;boot from the disk and then run the utility.&amp;nbsp; It's self-explanatory from there.&lt;/P&gt;
&lt;P&gt;I wonder why this utility is no longer in the Resource Kits?&lt;/P&gt;
&lt;P&gt;Note:&amp;nbsp; I kept getting a &amp;#8220;Page Not Found&amp;#8221; error while trying to download the resource kit, but it eventually worked.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=166321" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/General/default.aspx">General</category></item><item><title>Parentheses and Order of Operations</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/06/10/152974.aspx</link><pubDate>Thu, 10 Jun 2004 20:59:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:152974</guid><dc:creator>bkcarroll</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=152974</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/06/10/152974.aspx#comments</comments><description>&lt;P&gt;It's a good idea to be explicit with parentheses when building arithmetic expressions.&amp;nbsp; For example, at first the following code doesn't look like it would cause a problem:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; i As &lt;FONT color=#0000ff&gt;Integer&lt;/FONT&gt; = 1&lt;BR&gt;i = i + i - i&lt;BR&gt;Console.Writeline(i)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Executing this code&amp;nbsp;will return 1 as you should expect.&amp;nbsp; But consider what happens in this case:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; i As &lt;FONT color=#0000ff&gt;Integer&lt;/FONT&gt; = i.MaxValue&lt;BR&gt;i = i + i - i&lt;BR&gt;Console.Writeline(i)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This code ends with an overflow error which could have been prevented by simply using parentheses like this:&lt;/P&gt;
&lt;P&gt;i = i + (i - i)&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=152974" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/General/default.aspx">General</category><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>Should programmers be able to convert from decimal to binary?</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/06/05/149044.aspx</link><pubDate>Sat, 05 Jun 2004 05:30:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:149044</guid><dc:creator>bkcarroll</dc:creator><slash:comments>33</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=149044</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/06/05/149044.aspx#comments</comments><description>&lt;P&gt;When I'm&amp;nbsp;interviewing candidates for a development&amp;nbsp;position&amp;nbsp;I typically write a number down and ask them to convert it from decimal to binary.&amp;nbsp; Of course this is a very minor factor in the interview, but I find it interesting to see their responses.&amp;nbsp; It amazes that onle &lt;STRONG&gt;one&amp;nbsp;&lt;/STRONG&gt;person&lt;STRONG&gt; &lt;/STRONG&gt;out of the last twenty five or thirty&amp;nbsp;candidates I've interviewed has been able to convert from decimal 45 to binary 00101101.&amp;nbsp;&amp;nbsp;(He also&amp;nbsp;proudly&amp;nbsp;did the hex conversion to&amp;nbsp;2D without missing a beat.)&amp;nbsp; Most of these candidates have CS degrees and 5+ years of experience, but from the looks on their faces when&amp;nbsp;asked this question,&amp;nbsp;they&amp;nbsp;either never learned or have forgotten one of the most fundamental concepts of computing.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Not only is it fundamental, it's also a&amp;nbsp;simple concept.&amp;nbsp; My&amp;nbsp;9 and 10 year old sons&amp;nbsp;can do these conversions.&amp;nbsp;&amp;nbsp;They can do all combinations of decimal/binary/hex conversions.&amp;nbsp; They think the binary system&amp;nbsp;is&amp;nbsp;the coolest&amp;nbsp;because&amp;nbsp;they can count to 1024 on their fingers.&amp;nbsp; Thankfully I waited until after they were 4 to teach them.&amp;nbsp; I could see it now...&amp;#8220;Hi Sweetie....how old are you?&amp;#8220; and them showing a binary 4 on their fingers!&lt;/P&gt;
&lt;P&gt;So, would the developers you work with be able to do these conversions (without a calculator) or would&amp;nbsp;they&amp;nbsp;go completely blank like my job candidates have been doing lately?&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=149044" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/General/default.aspx">General</category><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>Virtual Desktop Manager</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/05/19/135510.aspx</link><pubDate>Thu, 20 May 2004 01:34:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:135510</guid><dc:creator>bkcarroll</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=135510</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/05/19/135510.aspx#comments</comments><description>&lt;P&gt;I've been tinkering with Linux lately and one of my favorite KDE features&amp;nbsp;is the desktop switcher.&amp;nbsp; Tonight I&amp;nbsp;found&amp;nbsp;&lt;A href="http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/DeskmanPowertoySetup.exe"&gt;Virtual Desktop Manager&lt;/A&gt;, a Microsoft &lt;A href="http://www.microsoft.com/windowsxp/pro/downloads/powertoys.asp"&gt;PowerToy &lt;/A&gt;that does basically the same thing.&amp;nbsp; It looks promising so far.&lt;/P&gt;
&lt;P&gt;Update:&amp;nbsp; This thing was really flaky until I upgraded my RAM to 1GB.&amp;nbsp; As &lt;A href="http://msmvps.com/gbvb/"&gt;Girish&lt;/A&gt; pointed out, it would freeze under low memory conditions.&amp;nbsp; Also, one of my biggest gripes is that if I have VS.NET maximized on&amp;nbsp;desktop #1, switch to a different desktop, and then come back to desktop #1, VS.NET will no longer be maximized.&amp;nbsp; Nothing major...just a pain in the butt.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=135510" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/General/default.aspx">General</category><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>Book Gripe</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/05/13/131453.aspx</link><pubDate>Thu, 13 May 2004 21:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:131453</guid><dc:creator>bkcarroll</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=131453</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/05/13/131453.aspx#comments</comments><description>&lt;P&gt;While reading chapter 4 of&amp;nbsp;the MSPress &amp;#8220;Inside Microsoft Visual Studio.NET&amp;#8220; book, I ran across this paragraph:&lt;/P&gt;
&lt;P&gt;&amp;#8220;&lt;EM&gt;By right-clicking on a macro in Macro Explorer, you can bring up a shortcut menu that lets you work with the macro directly.&amp;nbsp; The Run command executes the Tools.Run command on the currently selected macro.&amp;nbsp; The Rename command allows you to edit the name of the macro in place.&amp;nbsp; The change you make to the name is reflected in the method name in the Macros IDE.&amp;nbsp; The Delete command deletes the currently selected macro.&amp;nbsp; And finally, the Edit command opens the current macro in the Macros IDE&lt;/EM&gt;.&amp;#8221;&lt;/P&gt;
&lt;P&gt;Now come on...who is the intended audience&amp;nbsp;for this book?&amp;nbsp;&amp;nbsp;I've never written a book,&amp;nbsp;but I have taught several Microsoft developer classes and appreciate the difficulty of gearing&amp;nbsp;content to a wide range of skill levels at one time.&amp;nbsp; But is it really necessary to go to such a low common denominator?&amp;nbsp; Surely anyone reading this book knows how to use a GUI and will understand that the delete command will delete the currently selected item.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Nevertheless, I've skipped all around this book getting the pieces I need and other than these types of annoyances, it's a&amp;nbsp;very informative&amp;nbsp;book.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=131453" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/General/default.aspx">General</category><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item><item><title>Be careful using a datetime column as part of a primary key</title><link>http://weblogs.asp.net/bkcarroll/archive/2004/05/13/131329.aspx</link><pubDate>Thu, 13 May 2004 18:35:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:131329</guid><dc:creator>bkcarroll</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bkcarroll/rsscomments.aspx?PostID=131329</wfw:commentRss><comments>http://weblogs.asp.net/bkcarroll/archive/2004/05/13/131329.aspx#comments</comments><description>&lt;P&gt;For no appartent reason an app that had worked fine for&amp;nbsp;two years&amp;nbsp;all of a sudden started failing with primary key violoations.&amp;nbsp; Of course I had &amp;#8220;optimized&amp;#8220; it shortly before it started failing, but&amp;nbsp; I didn't see how&amp;nbsp;my changes&amp;nbsp;could have caused this problem.&amp;nbsp;&amp;nbsp;I only&amp;nbsp;removed a few lines of code and didn't change anything related to&amp;nbsp;data access.&amp;nbsp; My change was intended to make the code run faster, but nothing else.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Well, my changes sped it up and that's exactly what&amp;nbsp;was wrong.&amp;nbsp; Because it was running faster, data was being written to the database more often.&amp;nbsp; One of the fields being written was &amp;#8220;LastUpdate&amp;#8220; which&amp;nbsp;was defined as&amp;nbsp;datetime data&amp;nbsp;type and&amp;nbsp;was part of the primary key.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The datetime data type in SQL Server is only accurate to one three-hundredth of a second, so although the app&amp;nbsp;may&amp;nbsp;have been&amp;nbsp;passing two different values to SQL server for consecutive records, the values were being&amp;nbsp;rounded which was&amp;nbsp;causing the primary key violation.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;For example, assume I pass these values to a stored procedure:&lt;BR&gt;2004-05-13 13:12:19.393&lt;BR&gt;2004-05-13 13:12:19.394&lt;BR&gt;2004-05-13 13:12:19.395&lt;BR&gt;2004-05-13 13:12:19.396&lt;BR&gt;2004-05-13 13:12:19.397&lt;/P&gt;
&lt;P&gt;SQL Server rounds them to this:&lt;BR&gt;2004-05-13 13:12:19.393&lt;BR&gt;2004-05-13 13:12:19.393&lt;BR&gt;2004-05-13 13:12:19.397&lt;BR&gt;2004-05-13 13:12:19.397&lt;BR&gt;2004-05-13 13:12:19.397&lt;/P&gt;
&lt;P&gt;It's easy to see how this was causing my problem.&amp;nbsp; SQL Server always rounds to .000, .003, or .007 milliseconds.&lt;/P&gt;
&lt;P&gt;I found no reason to have the LastUpdate field as part of the primary key, so I removed it and all worked well.&amp;nbsp; Another lesson learned!&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=131329" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bkcarroll/archive/tags/.NET+Related/default.aspx">.NET Related</category></item></channel></rss>