Wednesday, July 25, 2007

Migrating SQL Server 2005 with the Migration Toolkit

I have a small website that I've built for my wife who is a realtor.  It's a simple site that tracks properties, showings, etc and it was built using ASP.Net and Sql Server.  Recently I decided to move it to Connector/Net and MySQL 5.1 so I needed a way to migrate the data.  Enter the MySQL Migration Toolkit.

This is a terrific tool that can migrate data from various databases into MySQL.  My SQL Server instance was setup to support mixed mode authentication and I had enabled the SQL Server Browser service and the TCP/IP protocol so I didn't anticipate any problems.  I was almost right.

The one thing that tripped me up was that I was using a named instance with SQL Server.  My instance was named SQLExpress so the hostname of the instance was .\SQLExpress.  The problem is that the JDBC driver that the toolkit uses doesn't accept that as a hostname.  To get it to work you have to enter a custom JDBC connection string and give the instance name as a property at the end of the string.

Once that was done the migration worked reasonably well.  A couple of tables generated syntax errors but I've been told that bug has been fixed and I  had to manually migrate my single stored function and single view.  Even with that, the toolkit saved me quite a bit of time.

Tuesday, July 24, 2007

Outlook style threading in Thunderbird

Unless you are tethered to Exchange, there really is no reason to use Outlook.  It's big, bloated, and, with the 2007 release, ridiculously slow. 

Still, there's always been one aspect to how it threads email messages that I liked.  When you viewed messages by conversation, it would bubble threads to the top when new messages for that thread arrived.  This had the effect of letting me see the freshest threads at the top of the stack.

Thunderbird is a far more capable email client but I've always disliked the fact that it orders the threads by the date of the first message in each thread.  Unless you are very organized and keep your inbox clean, you can easily lose messages when they are part of a very old thread.

It turns out that Thunderbird can sort messages the same way as Outlook.  The key is to tell each view to sort by date instead of order received.  Sorting by date will sort by the date of the last message in each thread while sorting by order received will be based on the date of the first message in each thread.  You can then choose ascending or descending on that same sort menu.  Now if I can just get a stable Outlook <-> Google calendar sync program running I will have no reason to run Outlook 2007 at all.

Friday, July 20, 2007

Trust the docs, except when they are wrong

I've been getting quite a few reports that my 5.0 and 5.1 installers don't work on Vista.  The reports all say that near the end of the install, it errors out with an error code of 2869. 

As a side note, I have yet to have an MSI error code that had a description that I  understood.  The description is almost always something like 'The transaction failed to start'.  These descriptions don't tell me anything.  But I digress.

This 2869 issue was hard to reproduce and very random.  After some work I found a 32 bit Vista machine that showed the problem.  With some trial and error and installutil style debugging I discovered that the problem was in my custom installer class.  Inside the MySql.Data assembly, we have a custom installer class that does two things.  First it adds the assembly to the system's machine.config file and then it adds a couple of performance counters.  With some additional testing, I found that the performance counter code was failing. 

The code calls PerformanceCounterCategory.Exists() to determine if the category already exists.  This call was throwing a FormatException with the message 'The input string was not in the correct format'.  Now if I check the handy dandy docs for this method, it clearly tells me that this method might throw one of three exceptions (ArgumentNullException, ArgumentException, or Win32Exception).  How is anyone supposed to make sense of a FormatException that is generated deep inside the bowels of the framework? [This is the reason for the blog title, BTW]

I found a blog post that referred to using the PerformanceCounterInstaller class.  The surface area of the .NET framework never ceases to amaze me.  I've been using it now for > 4 years and I still discover new classes almost weekly.  Thinking I had solved my problem, I replaced my code with calls to this new class.  Nope.  Still the error remains.  Back to Google.

Finally I discovered others who had this problem and found out that the registry information for the performance counters can become corrupt and read about the 'lodctr' tool.  This tool has a parameter (/R) that restores the registry settings either from a file or from the system store.  Running lodctr /R on the affected systems rolls the perfmon registry settings back to the latest system store but solves the FormatException problem when trying to install new performance counters.

Who builds this stuff?

No matter what system you run there are areas that just don't make any sense.  I love Visual Studio and will argue with anyone that it's the best way to develop traditional platform applications.  That being said, it's help system is quite ridiculous.

You would think that a company that is so focused on developer productivity would make it trivial to integrate third-party documentation.  The pages of the documentation are all just HTML files.  Each documentation package might contain some indexes but on the whole it's just HTML.  Here's an idea.  Just make the help format a zip archive and inside this zip you layout the HTML in whatever tree structure you like.  Include whatever scripts, CSS, or binary content you like.  Any top level pages that should not appear in the TOC can be listed in some .exclude file.  There can be a file that lists the name to file indexes.  All of this could then be neatly compressed inside a zip archive.

Anyway, I didn't  use Robohelp or any other commercial product.  Instead I used Sandcastle and the excellent NDoc replacement Sandcastle Help File Builder.  This tool works with the latest Sandcastle bits and builds both CHM and HxS style help files.  While SHFB allows me to integrate additional HTML content, the current version (1.5.0.1) has a bug that keeps it from being able to generate a root namespace.  I wanted my namespace documentation to be listed under a node named 'Reference'.  Luckily this project is open source and Eric has already made available a patch that fixes this issue.

The next problem was that the normal VS2005 Help Merge Module project would not integrate the generated HxS correctly.  I tried other Sandcastle generated files and they worked ok but mine simply refused.  I would up using the terrific FAR tools to hand tweak the collection files to get my table of contents working right.

The next thing I have to work on is integrating the Connector/Net portions of our online manual.  I've already discussed this with our docs team and we think we have an approach.  Wish us luck.  ;)

Blog Moved!

I have officially moved my blog from www.bytefx.com/blog to www.reggieburnett.com.  Please update your links, bookmarks, readers, etc.  I have attempted to preserve as many of the old dasBlog URLs as I can but I know of at least 3 URL types that are not working currently.  I'll try to get those working over the weekend.  If you find any old URL that is not working, please drop me a line so I can fix it.

Thanks!

Oh yeah!

I had been thinking of moving my blog for some time now.  I started my blog back when I was self-employed and operating under the corporate name ByteFX.  I have been employed by MySQL now for more than 3 years and been blogging about all things .NET and MySQL at my ByteFX site.  While technically there is nothing wrong with this, it always felt wrong to me to blog about my efforts at my current employment under a different corporate website.  The domain name 'reggieburnett.com' was available so I jumped.

GoDaddy.com offers some very cheap Windows hosting so I decided to host my new site and blog there.  They offer a very professional setup and the only real hang up was that my site had to be medium trust compatible.  dasBlog, my current blog software of choice, is not.  So I made the move to Subtext, a BSD-licensed fork of .Text.  It's simple, SQL-based (soon to support MySQL), includes a photo gallery, and works under medium trust.  Sold.  Now I need to move my current blog to Subtext.  Here's where the rubber meets the road.

While Subtext can import BlogML data, dasBlog doesn't support BlogML export.  After asking on the dasBlog mailing list, I found a blog post here that includes a BlogML import/export tool.  After a few tweaks, I managed to generate a fairly large BlogML file that imported cleanly into Subtext.  I also found this page that I basically followed the rest of the way home.

A few support calls to GoDaddy.com, a few code changes to the IHttpHandler included on the referenced page, and I had my old blog moved over and most old dasBlog links working.  I still don't have CategoryView, month view, or default.aspx#{guid} style urls working but I'll hack on those tomorrow.

I'll send out a separate (and more brief) announcement but my blog has officially moved from www.bytefx.com/blog to www.reggieburnett.com.  Please update your bookmarks and reader subscriptions appropriately.  Thanks!